awl/main_test.go
Sam 4cf19ebf78
All checks were successful
continuous-integration/drone/push Build is passing
Another "minor refactor" (#61)
I need to make fewer of these :)
Reviewed-on: #61
2022-08-11 07:25:36 +00:00

41 lines
690 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
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
}