Add test for jobs (#34)

This commit is contained in:
Jonas Plum
2022-02-27 18:33:50 +01:00
committed by GitHub
parent fd18458f3d
commit ffba7b4f5f
18 changed files with 181 additions and 80 deletions

View File

@@ -67,13 +67,13 @@ func TestServer(t *testing.T) {
t.Fatalf("Status got = %v (%s), want %v", result.Status, msg, tt.Want.Status)
}
if tt.Want.Status != http.StatusNoContent {
jsonEqual(t, result.Body, tt.Want.Body)
jsonEqual(t, tt.Name, result.Body, tt.Want.Body)
}
})
}
}
func jsonEqual(t *testing.T, got io.Reader, want interface{}) {
func jsonEqual(t *testing.T, name string, got io.Reader, want interface{}) {
var gotObject, wantObject interface{}
// load bytes
@@ -86,7 +86,15 @@ func jsonEqual(t *testing.T, got io.Reader, want interface{}) {
t.Fatal(err)
}
fields := []string{"secret"}
var fields []string
if name == "CreateUser" {
fields = append(fields, "secret")
}
if name == "RunJob" {
fields = append(fields, "id", "status")
}
for _, field := range fields {
gField := gjson.GetBytes(wantBytes, field)
if gField.Exists() && gjson.GetBytes(gotBytes, field).Exists() {