awl/main_test.go
Sam Therapy 530ef06ee1
All checks were successful
continuous-integration/drone/push Build is passing
feat: Trace (#162)
This PR should add the trace option, used by +trace and --trace

TODO
- [x] Making the trace work properly
- [x] Documentation adding
- [x] Completion adding

Co-authored-by: grumbulon <grumbulon@grumbulon.xyz>
Reviewed-on: #162
Reviewed-by: grumbulon <grumbulon@grumbulon.xyz>
2022-12-10 17:51:49 +00:00

48 lines
967 B
Go

// SPDX-License-Identifier: BSD-3-Clause
package main
import (
"testing"
"github.com/stefansundin/go-zflag"
"gotest.tools/v3/assert"
)
func TestRun(t *testing.T) {
// t.Parallel()
args := [][]string{
{"awl", "+yaml", "@1.1.1.1"},
{"awl", "+short", "@1.1.1.1"},
}
for _, test := range args {
test := test
t.Run("", func(t *testing.T) {
_, code, err := run(test)
assert.NilError(t, err)
assert.Equal(t, code, 0)
})
}
}
func TestTrace(t *testing.T) {
domains := []string{"git.froth.zone", "google.com", "amazon.com", "freecumextremist.com", "dns.froth.zone", "sleepy.cafe", "pkg.go.dev"}
for i := range domains {
args := []string{"awl", "+trace", domains[i], "@1.1.1.1"}
_, code, err := run(args)
assert.NilError(t, err)
assert.Equal(t, code, 0)
}
}
func TestHelp(t *testing.T) {
// t.Parallel()
args := []string{"awl", "-h"}
_, code, err := run(args)
assert.ErrorIs(t, err, zflag.ErrHelp)
assert.Equal(t, code, 1)
}