awl/main_test.go
Sam Therapy 81da49093d
All checks were successful
continuous-integration/drone/push Build is passing
refactor: Make all calls to options pointers (#132)
Instead of copying the opts struct every time it gets passed around, it should be created once and passed through reference.

This should reduce memory utilization, unfortunately I cannot test it since this program runs so fast pprof won't report anything useful.

I think I found all of them 🙂

Co-authored-by: Sam Therapy <sam@samtherapy.net>
Reviewed-on: #132
Reviewed-by: grumbulon <grumbulon@grumbulon.xyz>
2022-10-13 12:49:36 +00:00

38 lines
624 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 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)
}