Skip to content

Commit

Permalink
Use fmt.Fprintf in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
np5 committed Jan 12, 2023
1 parent 658ceed commit 11efca0
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 30 deletions.
40 changes: 20 additions & 20 deletions jmespath_checks_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ func TestJMESPathChecksService_List(t *testing.T) {
mux.HandleFunc("/inventory/jmespath_checks/", func(w http.ResponseWriter, r *http.Request) {
testMethod(t, r, "GET")
testHeader(t, r, "Accept", "application/json")
fmt.Fprint(w, fmt.Sprintf(`[{"id":1,"name":"yolo","description":"desc",
"source_name":"source","platforms":["MACOS"],"tags":[18,29],
"jmespath_expression":"ok","version":3,
"created_at":%[1]s,"updated_at":%[1]s}]`, referenceTimeStr))
fmt.Fprintf(w, `[{"id":1,"name":"yolo","description":"desc",
"source_name":"source","platforms":["MACOS"],"tags":[18,29],
"jmespath_expression":"ok","version":3,
"created_at":%[1]s,"updated_at":%[1]s}]`, referenceTimeStr)
})

ctx := context.Background()
Expand Down Expand Up @@ -52,10 +52,10 @@ func TestJMESPathChecksService_GetByID(t *testing.T) {
mux.HandleFunc("/inventory/jmespath_checks/1/", func(w http.ResponseWriter, r *http.Request) {
testMethod(t, r, "GET")
testHeader(t, r, "Accept", "application/json")
fmt.Fprint(w, fmt.Sprintf(`{"id":17,"name":"yolo","description":"desc",
"source_name":"source","platforms":["MACOS"],
"jmespath_expression":"ok","version":3,
"created_at":%[1]s,"updated_at":%[1]s}`, referenceTimeStr))
fmt.Fprintf(w, `{"id":17,"name":"yolo","description":"desc",
"source_name":"source","platforms":["MACOS"],
"jmespath_expression":"ok","version":3,
"created_at":%[1]s,"updated_at":%[1]s}`, referenceTimeStr)
})

ctx := context.Background()
Expand Down Expand Up @@ -88,10 +88,10 @@ func TestJMESPathChecksService_GetByName(t *testing.T) {
testMethod(t, r, "GET")
testHeader(t, r, "Accept", "application/json")
testQueryArg(t, r, "name", "yolo")
fmt.Fprint(w, fmt.Sprintf(`[{"id":18,"name":"yolo","description":"desc",
"source_name":"source",
"jmespath_expression":"ok","version":3,
"created_at":%[1]s,"updated_at":%[1]s}]`, referenceTimeStr))
fmt.Fprintf(w, `[{"id":18,"name":"yolo","description":"desc",
"source_name":"source",
"jmespath_expression":"ok","version":3,
"created_at":%[1]s,"updated_at":%[1]s}]`, referenceTimeStr)
})

ctx := context.Background()
Expand Down Expand Up @@ -124,10 +124,10 @@ func TestJMESPathChecksService_Create(t *testing.T) {
testHeader(t, r, "Accept", "application/json")
testHeader(t, r, "Content-Type", "application/json")
testBody(t, r, `{"name":"yolo","description":"desc","source_name":"source","platforms":["MACOS"],"tags":[18,29],"jmespath_expression":"ok"}`+"\n")
fmt.Fprint(w, fmt.Sprintf(`{"id":19,"name":"yolo","description":"desc",
"source_name":"source","platforms":["MACOS"],"tags":[18,29],
"jmespath_expression":"ok","version":3,
"created_at":%[1]s,"updated_at":%[1]s}`, referenceTimeStr))
fmt.Fprintf(w, `{"id":19,"name":"yolo","description":"desc",
"source_name":"source","platforms":["MACOS"],"tags":[18,29],
"jmespath_expression":"ok","version":3,
"created_at":%[1]s,"updated_at":%[1]s}`, referenceTimeStr)
})

ctx := context.Background()
Expand Down Expand Up @@ -172,10 +172,10 @@ func TestJMESPathChecksService_Update(t *testing.T) {
testHeader(t, r, "Accept", "application/json")
testHeader(t, r, "Content-Type", "application/json")
testBody(t, r, `{"name":"yolo1","description":"","source_name":"source","platforms":["MACOS"],"tags":[],"jmespath_expression":"ok"}`+"\n")
fmt.Fprint(w, fmt.Sprintf(`{"id":1,"name":"yolo1","description":"",
"source_name":"source","platforms":["MACOS"],"tags":[],
"jmespath_expression":"ok","version":3,
"created_at":%[1]s,"updated_at":%[1]s}`, referenceTimeStr))
fmt.Fprintf(w, `{"id":1,"name":"yolo1","description":"",
"source_name":"source","platforms":["MACOS"],"tags":[],
"jmespath_expression":"ok","version":3,
"created_at":%[1]s,"updated_at":%[1]s}`, referenceTimeStr)
})

ctx := context.Background()
Expand Down
10 changes: 5 additions & 5 deletions meta_business_units_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ func TestMetaBusinessUnitsService_List(t *testing.T) {
mux.HandleFunc("/inventory/meta_business_units/", func(w http.ResponseWriter, r *http.Request) {
testMethod(t, r, "GET")
testHeader(t, r, "Accept", "application/json")
fmt.Fprint(w, fmt.Sprintf(`[{"id":1,"name":"yolo","api_enrollment_enabled":false,"created_at":%[1]s,"updated_at":%[1]s}]`, referenceTimeStr))
fmt.Fprintf(w, `[{"id":1,"name":"yolo","api_enrollment_enabled":false,"created_at":%[1]s,"updated_at":%[1]s}]`, referenceTimeStr)
})

ctx := context.Background()
Expand All @@ -38,7 +38,7 @@ func TestMetaBusinessUnitsService_GetByID(t *testing.T) {
mux.HandleFunc("/inventory/meta_business_units/1/", func(w http.ResponseWriter, r *http.Request) {
testMethod(t, r, "GET")
testHeader(t, r, "Accept", "application/json")
fmt.Fprint(w, fmt.Sprintf(`{"id":1,"name":"yolo","api_enrollment_enabled":false,"created_at":%[1]s,"updated_at":%[1]s}`, referenceTimeStr))
fmt.Fprintf(w, `{"id":1,"name":"yolo","api_enrollment_enabled":false,"created_at":%[1]s,"updated_at":%[1]s}`, referenceTimeStr)
})

ctx := context.Background()
Expand All @@ -61,7 +61,7 @@ func TestMetaBusinessUnitsService_GetByName(t *testing.T) {
testMethod(t, r, "GET")
testHeader(t, r, "Accept", "application/json")
testQueryArg(t, r, "name", "yolo")
fmt.Fprint(w, fmt.Sprintf(`[{"id":1,"name":"yolo","api_enrollment_enabled":false,"created_at":%[1]s,"updated_at":%[1]s}]`, referenceTimeStr))
fmt.Fprintf(w, `[{"id":1,"name":"yolo","api_enrollment_enabled":false,"created_at":%[1]s,"updated_at":%[1]s}]`, referenceTimeStr)
})

ctx := context.Background()
Expand All @@ -85,7 +85,7 @@ func TestMetaBusinessUnitsService_Create(t *testing.T) {
testHeader(t, r, "Accept", "application/json")
testHeader(t, r, "Content-Type", "application/json")
testBody(t, r, `{"name":"yolo","api_enrollment_enabled":false}`+"\n")
fmt.Fprint(w, fmt.Sprintf(`{"id":1,"name":"yolo","api_enrollment_enabled":false,"created_at":%[1]s,"updated_at":%[1]s}`, referenceTimeStr))
fmt.Fprintf(w, `{"id":1,"name":"yolo","api_enrollment_enabled":false,"created_at":%[1]s,"updated_at":%[1]s}`, referenceTimeStr)
})

ctx := context.Background()
Expand All @@ -109,7 +109,7 @@ func TestMetaBusinessUnitsService_Update(t *testing.T) {
testHeader(t, r, "Accept", "application/json")
testHeader(t, r, "Content-Type", "application/json")
testBody(t, r, `{"name":"yolo1","api_enrollment_enabled":false}`+"\n")
fmt.Fprint(w, fmt.Sprintf(`{"id":1,"name":"yolo1","api_enrollment_enabled":false,"created_at":%[1]s,"updated_at":%[1]s}`, referenceTimeStr))
fmt.Fprintf(w, `{"id":1,"name":"yolo1","api_enrollment_enabled":false,"created_at":%[1]s,"updated_at":%[1]s}`, referenceTimeStr)
})

ctx := context.Background()
Expand Down
10 changes: 5 additions & 5 deletions taxonomies_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ func TestTaxonomiesService_List(t *testing.T) {
mux.HandleFunc("/inventory/taxonomies/", func(w http.ResponseWriter, r *http.Request) {
testMethod(t, r, "GET")
testHeader(t, r, "Accept", "application/json")
fmt.Fprint(w, fmt.Sprintf(`[{"id":1,"meta_business_unit":1,"name":"yolo","created_at":%[1]s,"updated_at":%[1]s}]`, referenceTimeStr))
fmt.Fprintf(w, `[{"id":1,"meta_business_unit":1,"name":"yolo","created_at":%[1]s,"updated_at":%[1]s}]`, referenceTimeStr)
})

ctx := context.Background()
Expand All @@ -38,7 +38,7 @@ func TestTaxonomiesService_GetByID(t *testing.T) {
mux.HandleFunc("/inventory/taxonomies/1/", func(w http.ResponseWriter, r *http.Request) {
testMethod(t, r, "GET")
testHeader(t, r, "Accept", "application/json")
fmt.Fprint(w, fmt.Sprintf(`{"id":1,"meta_business_unit":null,"name":"yolo","created_at":%[1]s,"updated_at":%[1]s}`, referenceTimeStr))
fmt.Fprintf(w, `{"id":1,"meta_business_unit":null,"name":"yolo","created_at":%[1]s,"updated_at":%[1]s}`, referenceTimeStr)
})

ctx := context.Background()
Expand All @@ -61,7 +61,7 @@ func TestTaxonomiesService_GetByName(t *testing.T) {
testMethod(t, r, "GET")
testHeader(t, r, "Accept", "application/json")
testQueryArg(t, r, "name", "yolo")
fmt.Fprint(w, fmt.Sprintf(`[{"id":1,"meta_business_unit":1,"name":"yolo","created_at":%[1]s,"updated_at":%[1]s}]`, referenceTimeStr))
fmt.Fprintf(w, `[{"id":1,"meta_business_unit":1,"name":"yolo","created_at":%[1]s,"updated_at":%[1]s}]`, referenceTimeStr)
})

ctx := context.Background()
Expand All @@ -85,7 +85,7 @@ func TestTaxonomiesService_Create(t *testing.T) {
testHeader(t, r, "Accept", "application/json")
testHeader(t, r, "Content-Type", "application/json")
testBody(t, r, `{"name":"yolo","meta_business_unit":1}`+"\n")
fmt.Fprint(w, fmt.Sprintf(`{"id":1,"meta_business_unit":1,"name":"yolo","created_at":%[1]s,"updated_at":%[1]s}`, referenceTimeStr))
fmt.Fprintf(w, `{"id":1,"meta_business_unit":1,"name":"yolo","created_at":%[1]s,"updated_at":%[1]s}`, referenceTimeStr)
})

ctx := context.Background()
Expand All @@ -109,7 +109,7 @@ func TestTaxonomiesService_Update(t *testing.T) {
testHeader(t, r, "Accept", "application/json")
testHeader(t, r, "Content-Type", "application/json")
testBody(t, r, `{"name":"yolo1","meta_business_unit":null}`+"\n")
fmt.Fprint(w, fmt.Sprintf(`{"id":1,"meta_business_unit":null,"name":"yolo1","created_at":%[1]s,"updated_at":%[1]s}`, referenceTimeStr))
fmt.Fprintf(w, `{"id":1,"meta_business_unit":null,"name":"yolo1","created_at":%[1]s,"updated_at":%[1]s}`, referenceTimeStr)
})

ctx := context.Background()
Expand Down

0 comments on commit 11efca0

Please sign in to comment.