Skip to content
This repository has been archived by the owner on Feb 17, 2024. It is now read-only.

don't use the default configuration in tests #46

Merged
merged 1 commit into from
Jun 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,11 @@ func (suite tests) run(t *testing.T) {
t.Run(name, func(t *testing.T) {
b, err := yaml.Marshal(configuration{
Registry: registry{
Location: t.TempDir(),
// Add a "one/two" subdirectory because the path is unlikely
// to be used in the code, and it will detect a regression
// if using a non-existing directory causes the program to
// fail.
Location: filepath.Join(t.TempDir(), "one", "two"),
},
Cache: cache{
Location: os.Getenv("TIMECRAFT_TEST_CACHE"),
Expand Down
10 changes: 0 additions & 10 deletions run_test.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package main_test

import (
"path/filepath"
"testing"

"github.com/stealthrocket/timecraft/internal/assert"
Expand All @@ -21,13 +20,4 @@ var run = tests{
assert.HasPrefix(t, stdout, "Usage:\ttimecraft run ")
assert.Equal(t, stderr, "")
},

"running with a configuration file which does not exist uses the default location": func(t *testing.T) {
t.Setenv("TIMECRAFTCONFIG", filepath.Join(t.TempDir(), "path", "to", "nowehere.yaml"))

stdout, stderr, exitCode := timecraft(t, "run", "./testdata/go/sleep.wasm", "0")
assert.Equal(t, exitCode, 0)
assert.Equal(t, stdout, "sleeping for 0s\n")
assert.NotEqual(t, stderr, "")
},
}
Loading