Skip to content

Commit

Permalink
test(config): override found interface
Browse files Browse the repository at this point in the history
  • Loading branch information
claudiodangelis committed Nov 13, 2023
1 parent f41de0f commit 9392370
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 7 deletions.
12 changes: 7 additions & 5 deletions config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ import (
func TestNew(t *testing.T) {
os.Clearenv()
_, f, _, _ := runtime.Caller(0)
foundIface, err := chooseInterface(application.Flags{})
if err != nil {
panic(err)
}
testdir := filepath.Join(filepath.Dir(f), "testdata")
tempfile, err := ioutil.TempFile("", "qrcp*tmp.yml")
if err != nil {
Expand All @@ -31,10 +35,6 @@ func TestNew(t *testing.T) {
type args struct {
app application.App
}
foundIface, err := chooseInterface(application.Flags{})
if err != nil {
panic(err)
}
tests := []struct {
name string
args args
Expand Down Expand Up @@ -123,7 +123,9 @@ func TestNew(t *testing.T) {
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if got := New(tt.args.app); !reflect.DeepEqual(got, tt.want) {
got := New(tt.args.app)
got.Interface = foundIface
if !reflect.DeepEqual(got, tt.want) {
t.Errorf("New() = %v, want %v", got, tt.want)
}
})
Expand Down
2 changes: 1 addition & 1 deletion config/testdata/full.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
interface: wlo1
interface: __PLACEHOLDER_INTERFACE__
port: 18080
bind: '10.20.30.40'
keepAlive: false
Expand Down
2 changes: 1 addition & 1 deletion config/testdata/qrcp.yml
Original file line number Diff line number Diff line change
@@ -1 +1 @@
interface: wlo1
interface: __PLACEHOLDER_INTERFACE__

0 comments on commit 9392370

Please sign in to comment.