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

Commit

Permalink
Merge pull request #46 from stealthrocket/timecraft-tests-dont-use-de…
Browse files Browse the repository at this point in the history
…fault-config

don't use the default configuration in tests
  • Loading branch information
achille-roussel committed Jun 1, 2023
2 parents a45fa56 + ec33bf1 commit c3ae913
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 11 deletions.
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, "")
},
}

0 comments on commit c3ae913

Please sign in to comment.