Skip to content

Commit

Permalink
revert using assert library
Browse files Browse the repository at this point in the history
  • Loading branch information
sfc-gh-knozderko committed Oct 13, 2023
1 parent 67b8571 commit ac5b900
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 18 deletions.
38 changes: 24 additions & 14 deletions client_configuration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ package gosnowflake

import (
"fmt"
"github.com/stretchr/testify/assert"
"os"
"path"
"strings"
Expand Down Expand Up @@ -60,10 +59,15 @@ func TestParseConfiguration(t *testing.T) {

config, err := parseClientConfiguration(fileName)

assert := assert.New(t)
assert.Equal(nil, err, "Error should be nil")
assert.Equal(tc.ExpectedLogLevel, config.Common.LogLevel, "Log level should be as expected")
assert.Equal(tc.ExpectedLogPath, config.Common.LogPath, "Log path should be as expected")
if err != nil {
t.Fatalf("Error should be nil but was %s", err)
}
if config.Common.LogLevel != tc.ExpectedLogLevel {
t.Errorf("Log level should be %s but was %s", tc.ExpectedLogLevel, config.Common.LogLevel)
}
if config.Common.LogPath != tc.ExpectedLogPath {
t.Errorf("Log path should be %s but was %s", tc.ExpectedLogPath, config.Common.LogPath)
}
})
}
}
Expand All @@ -82,9 +86,12 @@ func TestParseAllLogLevels(t *testing.T) {

config, err := parseClientConfiguration(fileName)

assert := assert.New(t)
assert.Equal(nil, err, "Error should be nil")
assert.Equal(logLevel, config.Common.LogLevel, "Log level should be as expected")
if err != nil {
t.Fatalf("Error should be nil but was: %s", err)
}
if config.Common.LogLevel != logLevel {
t.Errorf("Log level should be %s but was %s", logLevel, config.Common.LogLevel)
}
})
}
}
Expand Down Expand Up @@ -143,14 +150,17 @@ func TestParseConfigurationFails(t *testing.T) {

_, err := parseClientConfiguration(fileName)

assert := assert.New(t)
assert.Equal(err != nil, true, "Error should not be nil")
if err == nil {
t.Fatal("Error should not be nil but was nil")
}
errMessage := fmt.Sprint(err)
expectedPrefix := "parsing client config failed"
assert.Equal(strings.HasPrefix(errMessage, expectedPrefix), true,
fmt.Sprintf("Error message: \"%s\" should start with prefix: \"%s\"", errMessage, expectedPrefix))
assert.Equal(strings.Contains(errMessage, tc.ExpectedErrorMessageToContain), true,
fmt.Sprintf("Error message: \"%s\" should contain given phrase: \"%s\"", errMessage, tc.ExpectedErrorMessageToContain))
if !strings.HasPrefix(errMessage, expectedPrefix) {
t.Errorf("Error message: \"%s\" should start with prefix: \"%s\"", errMessage, expectedPrefix)
}
if !strings.Contains(errMessage, tc.ExpectedErrorMessageToContain) {
t.Errorf("Error message: \"%s\" should contain given phrase: \"%s\"", errMessage, tc.ExpectedErrorMessageToContain)
}
})
}
}
Expand Down
5 changes: 1 addition & 4 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ require (
github.com/gabriel-vasile/mimetype v1.4.2
github.com/pkg/browser v0.0.0-20210911075715-681adbf594b8
github.com/sirupsen/logrus v1.9.0
github.com/stretchr/testify v1.8.1
golang.org/x/crypto v0.7.0
)

Expand All @@ -35,7 +34,6 @@ require (
github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.9.25 // indirect
github.com/aws/aws-sdk-go-v2/service/internal/s3shared v1.14.0 // indirect
github.com/danieljoos/wincred v1.1.2 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/dvsekhvalnov/jose2go v1.5.0 // indirect
github.com/goccy/go-json v0.10.0 // indirect
github.com/godbus/dbus v0.0.0-20190726142602-4481cbc300e2 // indirect
Expand All @@ -52,7 +50,7 @@ require (
github.com/minio/c2goasm v0.0.0-20190812172519-36a3d3bbc4f3 // indirect
github.com/mtibben/percent v0.2.1 // indirect
github.com/pierrec/lz4/v4 v4.1.17 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/stretchr/testify v1.8.1 // indirect
github.com/zeebo/xxh3 v1.0.2 // indirect
golang.org/x/exp v0.0.0-20230206171751-46f607a40771 // indirect
golang.org/x/mod v0.8.0 // indirect
Expand All @@ -63,5 +61,4 @@ require (
golang.org/x/text v0.8.0 // indirect
golang.org/x/tools v0.6.0 // indirect
golang.org/x/xerrors v0.0.0-20220907171357-04be3eba64a2 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)

0 comments on commit ac5b900

Please sign in to comment.