awl/conf/plan9_test.go
Sam Therapy 193a41ed9c refactor: (test): make them less ugly
This should make tests more readable

Signed-off-by: Sam Therapy <sam@samtherapy.net>
2022-09-17 10:59:39 +00:00

77 lines
1.7 KiB
Go

// SPDX-License-Identifier: BSD-3-Clause
//go:build plan9
package conf_test
import (
"runtime"
"testing"
"git.froth.zone/sam/awl/conf"
"gotest.tools/v3/assert"
)
func TestPlan9Config(t *testing.T) {
t.Parallel()
if runtime.GOOS != "plan9" {
t.Skip("Not running Plan 9, skipping")
}
conf, err := conf.GetDNSConfig()
assert.NilError(t, err)
assert.Assert(t, len(conf.Servers) != 0)
}
// Old config grabber tests
// func TestGetValidPlan9Config(t *testing.T) {
// t.Parallel()
// if runtime.GOOS != "plan9" {
// t.Skip("Not running Plan 9, skipping")
// }
// ndbs := []struct {
// in string
// want string
// }{
// {`ip=192.168.122.45 ipmask=255.255.255.0 ipgw=192.168.122.1
// sys=chog9
// dns=192.168.122.1`, "192.168.122.1"},
// {`ipnet=murray-hill ip=135.104.0.0 ipmask=255.255.0.0
// dns=135.104.10.1
// ntp=ntp.cs.bell-labs.com
// ipnet=plan9 ip=135.104.9.0 ipmask=255.255.255.0
// ntp=oncore.cs.bell-labs.com
// smtp=smtp1.cs.bell-labs.com
// ip=135.104.9.6 sys=anna dom=anna.cs.bell-labs.com
// smtp=smtp2.cs.bell-labs.com`, "135.104.10.1"},
// }
// for _, ndb := range ndbs {
// // Go is a little quirky
// ndb := ndb
// t.Run(ndb.want, func(t *testing.T) {
// t.Parallel()
// act, err := conf.GetDNSConfig(ndb.in)
// assert.NilError(t, err)
// assert.Equal(t, ndb.want, act.Servers[0])
// })
// }
// }
// func TestInvalidPlan9Config(t *testing.T) {
// invalid := `sys = spindle
// dom=spindle.research.bell-labs.com
// bootf=/mips/9powerboot
// ip=135.104.117.32 ether=080069020677
// proto=il`
// act, err := conf.GetDNSConfig(invalid)
// assert.ErrorContains(t, err, "no DNS servers found")
// assert.Assert(t, act == nil)
// }