From c0b5bf0a368ad936e71f0826ec0c911036ecc3c8 Mon Sep 17 00:00:00 2001 From: Roy Han Date: Fri, 12 Jul 2024 11:45:45 -0700 Subject: [PATCH] testing clean up --- server/routes_test.go | 35 +++++++++++++++++++++++++++-------- 1 file changed, 27 insertions(+), 8 deletions(-) diff --git a/server/routes_test.go b/server/routes_test.go index 02c4ecd11..70622e9b0 100644 --- a/server/routes_test.go +++ b/server/routes_test.go @@ -288,16 +288,27 @@ func Test_Routes(t *testing.T) { }, Expected: func(t *testing.T, resp *http.Response) { contentType := resp.Header.Get("Content-Type") - assert.Equal(t, "application/json; charset=utf-8", contentType) + if contentType != "application/json; charset=utf-8" { + t.Fatalf("expected content type application/json; charset=utf-8, got %s", contentType) + } body, err := io.ReadAll(resp.Body) - require.NoError(t, err) + if err != nil { + t.Fatal(err) + } var embedResp api.EmbedResponse err = json.Unmarshal(body, &embedResp) - require.NoError(t, err) + if err != nil { + t.Fatal(err) + } - assert.Equal(t, "t-bone", embedResp.Model) - assert.Nil(t, embedResp.Embeddings) + if embedResp.Model != "t-bone" { + t.Fatalf("expected model t-bone, got %s", embedResp.Model) + } + + if embedResp.Embeddings != nil { + t.Fatalf("expected embeddings to be nil, got %v", embedResp.Embeddings) + } }, }, { @@ -315,10 +326,18 @@ func Test_Routes(t *testing.T) { }, Expected: func(t *testing.T, resp *http.Response) { contentType := resp.Header.Get("Content-Type") - assert.Equal(t, "application/json; charset=utf-8", contentType) + if contentType != "application/json; charset=utf-8" { + t.Fatalf("expected content type application/json; charset=utf-8, got %s", contentType) + } _, err := io.ReadAll(resp.Body) - require.NoError(t, err) - assert.Equal(t, 400, resp.StatusCode) + + if err != nil { + t.Fatal(err) + } + + if resp.StatusCode != http.StatusBadRequest { + t.Fatalf("expected status code 400, got %d", resp.StatusCode) + } }, }, }