awl/main_test.go
Sam Therapy 4c9221ee29
Some checks failed
continuous-integration/drone/push Build is failing
Another huge refactor/rework
:^)

Signed-off-by: Sam Therapy <sam@samtherapy.net>
2022-08-06 01:45:31 +02:00

42 lines
671 B
Go

// SPDX-License-Identifier: BSD-3-Clause
package main
import (
"os"
"testing"
"github.com/stefansundin/go-zflag"
"gotest.tools/v3/assert"
)
//nolint: paralleltest
func TestMain(t *testing.T) {
old := os.Args
os.Args = []string{"awl", "+yaml", "@1.1.1.1"}
_, code, err := run()
assert.NilError(t, err)
assert.Equal(t, code, 0)
os.Args = []string{"awl", "+short", "@1.1.1.1"}
_, code, err = run()
assert.NilError(t, err)
assert.Equal(t, code, 0)
os.Args = old
}
func TestHelp(t *testing.T) {
old := os.Args
os.Args = []string{"awl", "-h"}
_, code, err := run()
assert.ErrorIs(t, err, zflag.ErrHelp)
assert.Equal(t, code, 1)
os.Args = old
}