Skip to content

Commit

Permalink
Add more coverage for air init (#288)
Browse files Browse the repository at this point in the history
* Fix dlv port address already in use

# Conflicts:
#	runner/engine.go
#	runner/util_linux.go

* move to engine test
  • Loading branch information
xiantang authored Jun 5, 2022
1 parent dee5db6 commit 1d4d116
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
3 changes: 3 additions & 0 deletions runner/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,10 @@ func defaultConfig() config {
Bin: "./tmp/main",
Log: "build-errors.log",
IncludeExt: []string{"go", "tpl", "tmpl", "html"},
IncludeDir: []string{},
ExcludeFile: []string{},
ExcludeDir: []string{"assets", "tmp", "vendor", "testdata"},
ArgsBin: []string{},
ExcludeRegex: []string{"_test.go"},
Delay: 1000,
StopOnError: true,
Expand Down
26 changes: 26 additions & 0 deletions runner/engine_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -461,3 +461,29 @@ func TestRebuildWhenRunCmdUsingDLV(t *testing.T) {
t.Logf("engine stopped")
assert.True(t, checkPortConnectionRefused(port))
}

func TestWriteDefaultConfig(t *testing.T) {
port, f := GetPort()
f()
t.Logf("port: %d", port)

tmpDir := initTestEnv(t, port)
// change dir to tmpDir
if err := os.Chdir(tmpDir); err != nil {
t.Fatal(err)
}
writeDefaultConfig()
// check the file is exist
if _, err := os.Stat(dftTOML); err != nil {
t.Fatal(err)
}

// check the file content is right
actual, err := readConfig(dftTOML)
if err != nil {
t.Fatal(err)
}
expect := defaultConfig()

assert.Equal(t, expect, *actual)
}

0 comments on commit 1d4d116

Please sign in to comment.