3d434eedb8
Job Status Get and DB tidy up * initalquery * tests * shorttests * testing queries * job * solvedthequery * updatingdb * fixingtests * repotests * shorttests * docker * testspassed
46 lines
1.2 KiB
Go
46 lines
1.2 KiB
Go
package collector
|
|
|
|
import (
|
|
"fmt"
|
|
"queryorchestration/internal/database"
|
|
"queryorchestration/internal/database/repository"
|
|
"testing"
|
|
|
|
"github.com/google/uuid"
|
|
"github.com/stretchr/testify/assert"
|
|
)
|
|
|
|
func TestParseDBCollector(t *testing.T) {
|
|
c, err := parseDBCollector(nil)
|
|
assert.NoError(t, err)
|
|
assert.Nil(t, c)
|
|
|
|
minCleanV := int32(1)
|
|
minTextV := int32(2)
|
|
ogc := Collector{
|
|
JobID: uuid.New(),
|
|
MinCleanVersion: minCleanV,
|
|
MinTextVersion: minTextV,
|
|
Fields: map[string]uuid.UUID{
|
|
"example_key": uuid.New(),
|
|
},
|
|
}
|
|
c, err = parseDBCollector(&repository.Fullactivecollector{
|
|
Jobid: database.MustToDBUUID(ogc.JobID),
|
|
Mincleanversion: ogc.MinCleanVersion,
|
|
Mintextversion: ogc.MinTextVersion,
|
|
Fields: []byte(fmt.Sprintf("{\"example_key\":\"%s\"}", ogc.Fields["example_key"])),
|
|
})
|
|
assert.NoError(t, err)
|
|
assert.EqualExportedValues(t, ogc, *c)
|
|
|
|
ogc.MinCleanVersion = 0
|
|
ogc.MinTextVersion = 0
|
|
c, err = parseDBCollector(&repository.Fullactivecollector{
|
|
Jobid: database.MustToDBUUID(ogc.JobID),
|
|
Fields: []byte(fmt.Sprintf("{\"example_key\":\"%s\"}", ogc.Fields["example_key"])),
|
|
})
|
|
assert.NoError(t, err)
|
|
assert.EqualExportedValues(t, ogc, *c)
|
|
}
|