awl/main_test.go
Sam Therapy 1304afce16
Some checks failed
continuous-integration/drone/push Build is failing
continuous-integration/drone/pr Build is failing
more API stuffs
Signed-off-by: Sam Therapy <sam@samtherapy.net>
2022-09-15 12:47:00 +02: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)
}