Skip to content

Commit 79cf322

Browse files
authored
Merge pull request #119 from mahmednabil109/main
Use proper entities when test GET endpoint
2 parents 9fd8de1 + e8405e2 commit 79cf322

2 files changed

Lines changed: 7 additions & 7 deletions

File tree

cmds/admin_server/storage/mongo/mongo.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ func toMongoQuery(query storage.Query) bson.D {
5757

5858
if query.JobID != nil {
5959
q = append(q, bson.E{
60-
Key: "jobid",
60+
Key: "job_id",
6161
Value: *query.JobID,
6262
})
6363
}

tests/integ/admin_server/getlogs_test.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -80,14 +80,14 @@ func generateRandomLogs(db *mongo.Client, count int) error {
8080
return nil
8181
}
8282

83-
func queryLogsEndpoint(query server.Query, retrieveAll bool) (*storage.Result, int, error) {
83+
func queryLogsEndpoint(query server.Query, retrieveAll bool) (*server.Result, int, error) {
8484
u, err := url.Parse(*flagAdminEndpoint)
8585
if err != nil {
8686
return nil, 0, err
8787
}
8888

8989
var (
90-
result storage.Result
90+
result server.Result
9191
statusCode int
9292
currentPage uint = 0
9393
continueRetrieve bool = true
@@ -98,7 +98,7 @@ func queryLogsEndpoint(query server.Query, retrieveAll bool) (*storage.Result, i
9898
}
9999

100100
for continueRetrieve {
101-
var tmp storage.Result
101+
var tmp server.Result
102102

103103
q := u.Query()
104104
if query.JobID != nil {
@@ -148,7 +148,7 @@ func queryLogsEndpoint(query server.Query, retrieveAll bool) (*storage.Result, i
148148

149149
// assertEqualResults checks that the db and api results
150150
// have the same length and contains the same logdata
151-
func assertEqualResults(t *testing.T, expected []storage.Log, actual []storage.Log) {
151+
func assertEqualResults(t *testing.T, expected []mongoStorage.Log, actual []server.Log) {
152152
// check length
153153
if len(expected) != len(actual) {
154154
t.Fatal(fmt.Errorf("api and db results dose not have the same length: %d != %d", len(expected), len(actual)))
@@ -220,7 +220,7 @@ func TestLogQuery(t *testing.T) {
220220
PageSize: &pageSize,
221221
},
222222
dbQuery: bson.M{
223-
"jobid": jobID,
223+
"job_id": jobID,
224224
},
225225
},
226226
{
@@ -331,7 +331,7 @@ func TestLogQuery(t *testing.T) {
331331
tt.Fatal(err)
332332
}
333333
// get logs from database
334-
var dbLogs []storage.Log
334+
var dbLogs []mongoStorage.Log
335335
ctx, cancel := context.WithTimeout(context.Background(), *flagOperationTimeout)
336336
defer cancel()
337337
cur, err := collection.Find(ctx, testCase.dbQuery)

0 commit comments

Comments
 (0)