Skip to content

Commit

Permalink
More cwd
Browse files Browse the repository at this point in the history
  • Loading branch information
grahamgilbert committed May 22, 2024
1 parent deeab84 commit a0c0f19
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 10 deletions.
4 changes: 0 additions & 4 deletions tables/sofa/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,6 @@ go_test(
"sofa_info_test.go",
],
embed = [":sofa"],
embedsrcs = [
"test_data.json",
"test_etag.txt",
],
deps = [
"//pkg/utils",
"@com_github_stretchr_testify//assert",
Expand Down
24 changes: 18 additions & 6 deletions tables/sofa/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -285,26 +285,34 @@ func TestDownloadData(t *testing.T) {
}

func TestNewSofaClient(t *testing.T) {
client, err := NewSofaClient()
cwd, err := os.Getwd()
assert.NoError(t, err)
client, err := NewSofaClient(WithCacheDir(cwd))
assert.NoError(t, err)
assert.Equal(t, SofaV1URL, client.endpoint)
assert.NotNil(t, client.httpClient)
}

func TestWithHTTPClient(t *testing.T) {
client, err := NewSofaClient(WithHTTPClient(&http.Client{}))
cwd, err := os.Getwd()
assert.NoError(t, err)
client, err := NewSofaClient(WithHTTPClient(&http.Client{}), WithCacheDir(cwd))
assert.NoError(t, err)
assert.NotNil(t, client.httpClient)
}

func TestWithEndpoint(t *testing.T) {
client, err := NewSofaClient(WithURL("http://example.com"))
cwd, err := os.Getwd()
assert.NoError(t, err)
client, err := NewSofaClient(WithURL("http://example.com"), WithCacheDir(cwd)

Check failure on line 307 in tables/sofa/client_test.go

View workflow job for this annotation

GitHub Actions / lint

missing ',' before newline in argument list (typecheck)

Check failure on line 307 in tables/sofa/client_test.go

View workflow job for this annotation

GitHub Actions / lint

missing ',' before newline in argument list (typecheck)
assert.NoError(t, err)

Check failure on line 308 in tables/sofa/client_test.go

View workflow job for this annotation

GitHub Actions / lint

missing ',' before newline in argument list (typecheck)

Check failure on line 308 in tables/sofa/client_test.go

View workflow job for this annotation

GitHub Actions / lint

missing ',' before newline in argument list (typecheck)
assert.Equal(t, "http://example.com", client.endpoint)

Check failure on line 309 in tables/sofa/client_test.go

View workflow job for this annotation

GitHub Actions / lint

missing ',' before newline in argument list (typecheck)

Check failure on line 309 in tables/sofa/client_test.go

View workflow job for this annotation

GitHub Actions / lint

missing ',' before newline in argument list (typecheck)
}

Check failure on line 310 in tables/sofa/client_test.go

View workflow job for this annotation

GitHub Actions / lint

expected operand, found '}' (typecheck)

Check failure on line 310 in tables/sofa/client_test.go

View workflow job for this annotation

GitHub Actions / lint

expected operand, found '}' (typecheck)

func TestSetCachePaths(t *testing.T) {
client, err := NewSofaClient()
cwd, err := os.Getwd()
assert.NoError(t, err)
client, err := NewSofaClient(WiWithCacheDir(cwd))
assert.NoError(t, err)

client.setCachePaths()
Expand All @@ -326,7 +334,9 @@ func TestWithCacheDir(t *testing.T) {
}

Check failure on line 334 in tables/sofa/client_test.go

View workflow job for this annotation

GitHub Actions / lint

expected operand, found '}' (typecheck)

Check failure on line 334 in tables/sofa/client_test.go

View workflow job for this annotation

GitHub Actions / lint

expected operand, found '}' (typecheck)

func TestEtagPath(t *testing.T) {
client, err := NewSofaClient()
cwd, err := os.Getwd()
assert.NoError(t, err)
client, err := NewSofaClient(WWithCacheDir(cwd))
assert.NoError(t, err)

client.setCachePaths()
Expand All @@ -335,7 +345,9 @@ func TestEtagPath(t *testing.T) {
}

func TestCreateCacheDir(t *testing.T) {
client, err := NewSofaClient()
cwd, err := os.Getwd()
assert.NoError(t, err)
client, err := NewSofaClient(WiWithCacheDir(cwd))
assert.NoError(t, err)

err = client.createCacheDir()
Expand Down

0 comments on commit a0c0f19

Please sign in to comment.