Skip to content

Commit

Permalink
test tmp actions order
Browse files Browse the repository at this point in the history
  • Loading branch information
z0rr0 committed Jul 30, 2023
1 parent 536120c commit bc03f9a
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -212,11 +212,8 @@ func TestConfig_setFiles(t *testing.T) {
tmpDir = os.TempDir()
testConfigDir = path.Join(tmpDir, testDir, "config")
testCacheDir = path.Join(tmpDir, testDir, "cache")
err error
)
tmpFile, err := os.CreateTemp(testCacheDir, "ytapigo_caceh_*.json")
if err != nil {
t.Fatal(err)
}

cleanFunc := func() {
if e := os.RemoveAll(testDir); e != nil {
Expand All @@ -230,6 +227,10 @@ func TestConfig_setFiles(t *testing.T) {
if err = os.MkdirAll(testCacheDir, 0750); err != nil {
t.Fatal(err)
}
tmpFile, err := os.CreateTemp(testCacheDir, "ytapigo_caceh_*.json")
if err != nil {
t.Fatal(err)
}

// clean before and after tests
cleanFunc()
Expand Down Expand Up @@ -297,11 +298,11 @@ func TestConfig_setFiles(t *testing.T) {
AuthCache: tc.cacheFile,
}

tcErr := cfg.setFiles(tc.configDir, tc.cacheDir)
if tcErr != nil {
err := cfg.setFiles(tc.configDir, tc.cacheDir)
if err != nil {
if tc.err == "" {
t.Errorf("unexpected error: %v", tcErr)
} else if e := tcErr.Error(); !strings.HasPrefix(e, tc.err) {
t.Errorf("unexpected error: %v", err)
} else if e := err.Error(); !strings.HasPrefix(e, tc.err) {
t.Errorf("not match error: %q, but expected %q", e, tc.err)
}
return
Expand Down

0 comments on commit bc03f9a

Please sign in to comment.