Skip to content

Commit

Permalink
More tests
Browse files Browse the repository at this point in the history
  • Loading branch information
grahamgilbert committed Jul 11, 2024
1 parent 2736ee8 commit 2f78cf7
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions tables/sofa/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@ func TestDownloadData(t *testing.T) {
func TestNewSofaClient(t *testing.T) {
cwd, err := os.Getwd()
assert.NoError(t, err)
client, err := NewSofaClient(WithCacheDir(cwd))
client, err := NewSofaClient(WithCacheDir(cwd), WithUserAgent("test"))
assert.NoError(t, err)
assert.Equal(t, SofaV1URL, client.endpoint)
assert.NotNil(t, client.httpClient)
Expand All @@ -310,23 +310,23 @@ func TestNewSofaClient(t *testing.T) {
func TestWithHTTPClient(t *testing.T) {
cwd, err := os.Getwd()
assert.NoError(t, err)
client, err := NewSofaClient(WithHTTPClient(&http.Client{}), WithCacheDir(cwd))
client, err := NewSofaClient(WithHTTPClient(&http.Client{}), WithCacheDir(cwd), WithUserAgent("test"))
assert.NoError(t, err)
assert.NotNil(t, client.httpClient)
}

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

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

client.setCachePaths()
Expand All @@ -338,7 +338,7 @@ func TestSetCachePaths(t *testing.T) {
func TestWithCacheDir(t *testing.T) {
cwd, err := os.Getwd()
assert.NoError(t, err)
client, err := NewSofaClient(WithCacheDir(cwd))
client, err := NewSofaClient(WithCacheDir(cwd), WithUserAgent("test"))
assert.NoError(t, err)
defer os.Remove(client.cacheDir) //nolint:errcheck

Expand All @@ -350,7 +350,7 @@ func TestWithCacheDir(t *testing.T) {
func TestEtagPath(t *testing.T) {
cwd, err := os.Getwd()
assert.NoError(t, err)
client, err := NewSofaClient(WithCacheDir(cwd))
client, err := NewSofaClient(WithCacheDir(cwd), WithUserAgent("test"))
assert.NoError(t, err)

client.setCachePaths()
Expand All @@ -361,7 +361,7 @@ func TestEtagPath(t *testing.T) {
func TestCreateCacheDir(t *testing.T) {
cwd, err := os.Getwd()
assert.NoError(t, err)
client, err := NewSofaClient(WithCacheDir(cwd))
client, err := NewSofaClient(WithCacheDir(cwd), WithUserAgent("test"))
assert.NoError(t, err)

err = client.createCacheDir()
Expand Down

0 comments on commit 2f78cf7

Please sign in to comment.