mirror of
https://github.com/AdguardTeam/AdGuardHome.git
synced 2025-05-08 16:50:12 +03:00
all: resync with master
This commit is contained in:
parent
2fc1e258ed
commit
a829adad10
69 changed files with 1126 additions and 434 deletions
internal/aghnet
|
@ -1,71 +0,0 @@
|
|||
//go:build openbsd
|
||||
|
||||
package aghnet
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"io/fs"
|
||||
"testing"
|
||||
"testing/fstest"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
func TestIfaceHasStaticIP(t *testing.T) {
|
||||
const ifaceName = "em0"
|
||||
|
||||
confFile := fmt.Sprintf("etc/hostname.%s", ifaceName)
|
||||
|
||||
testCases := []struct {
|
||||
name string
|
||||
rootFsys fs.FS
|
||||
wantHas assert.BoolAssertionFunc
|
||||
}{{
|
||||
name: "simple",
|
||||
rootFsys: fstest.MapFS{
|
||||
confFile: &fstest.MapFile{
|
||||
Data: []byte(`inet 127.0.0.253` + nl),
|
||||
},
|
||||
},
|
||||
wantHas: assert.True,
|
||||
}, {
|
||||
name: "case_sensitiveness",
|
||||
rootFsys: fstest.MapFS{
|
||||
confFile: &fstest.MapFile{
|
||||
Data: []byte(`InEt 127.0.0.253` + nl),
|
||||
},
|
||||
},
|
||||
wantHas: assert.False,
|
||||
}, {
|
||||
name: "comments_and_trash",
|
||||
rootFsys: fstest.MapFS{
|
||||
confFile: &fstest.MapFile{
|
||||
Data: []byte(`# comment 1` + nl + nl +
|
||||
`# inet 127.0.0.253` + nl +
|
||||
`inet` + nl,
|
||||
),
|
||||
},
|
||||
},
|
||||
wantHas: assert.False,
|
||||
}, {
|
||||
name: "incorrect_config",
|
||||
rootFsys: fstest.MapFS{
|
||||
confFile: &fstest.MapFile{
|
||||
Data: []byte(`inet6 127.0.0.253` + nl + `inet 256.256.256.256` + nl),
|
||||
},
|
||||
},
|
||||
wantHas: assert.False,
|
||||
}}
|
||||
|
||||
for _, tc := range testCases {
|
||||
t.Run(tc.name, func(t *testing.T) {
|
||||
substRootDirFS(t, tc.rootFsys)
|
||||
|
||||
has, err := IfaceHasStaticIP(ifaceName)
|
||||
require.NoError(t, err)
|
||||
|
||||
tc.wantHas(t, has)
|
||||
})
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue