awl/main_test.go
Sam 9746ae0a6f
Some checks reported errors
continuous-integration/drone/push Build was killed
feat: more API work
Reviewed-on: #94
Reviewed-by: grumbulon <grumbulon@grumbulon.xyz>
2022-09-15 11:02:43 +00:00

36 lines
708 B
Go

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