Files
query-orchestration/internal/job/collector/parse_test.go
T
Michael McGuinness 5b7160fe44 Merged in fature/jobs (pull request #34)
Job Collector

* createstructure

* mostupdatevalidation

* repocollectorupdate

* updateoutline

* updatevalidation

* scriptupdate

* cleanupdockerignore

* update

* collectorupdateapi
2025-01-23 14:56:20 +00:00

49 lines
1.3 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.Nil(t, err)
assert.Nil(t, c)
minCleanV := int32(1)
minTextV := int32(2)
ogc := Collector{
ID: uuid.New(),
JobID: uuid.New(),
MinCleanVersion: minCleanV,
MinTextVersion: minTextV,
Fields: map[string]uuid.UUID{
"example_key": uuid.New(),
},
}
c, err = parseDBCollector(&repository.Fullactivecollector{
ID: database.MustToDBUUID(ogc.ID),
Jobid: database.MustToDBUUID(ogc.JobID),
Mincleanversion: &ogc.MinCleanVersion,
Mintextversion: &ogc.MinTextVersion,
Fields: []byte(fmt.Sprintf("{\"example_key\":\"%s\"}", ogc.Fields["example_key"])),
})
assert.Nil(t, err)
assert.EqualExportedValues(t, ogc, *c)
ogc.MinCleanVersion = 0
ogc.MinTextVersion = 0
c, err = parseDBCollector(&repository.Fullactivecollector{
ID: database.MustToDBUUID(ogc.ID),
Jobid: database.MustToDBUUID(ogc.JobID),
Fields: []byte(fmt.Sprintf("{\"example_key\":\"%s\"}", ogc.Fields["example_key"])),
})
assert.Nil(t, err)
assert.EqualExportedValues(t, ogc, *c)
}