go-spectre/cmd/spectre/main_test.go

42 lines
758 B
Go

package main
import (
_ "embed"
"go.jolheiser.com/go-spectre/testdata"
"testing"
)
// These are the exact same tests as spectre_test.go
// These are here just to make sure the CLI is giving the same outputs
func TestCLI(t *testing.T) {
cases, err := testdata.Cases()
if err != nil {
t.Log(err)
t.FailNow()
}
for _, tc := range cases {
t.Run(tc.ID, func(t *testing.T) {
args := []string{
"--username", tc.UserName,
"--secret", tc.UserSecret,
"--template", tc.ResultType,
"--counter", tc.KeyCounter,
"--scope", tc.KeyPurpose,
tc.SiteName,
}
pw, err := doMain(args)
if err != nil {
t.Log(err)
t.FailNow()
}
if pw != tc.Result {
t.Log("passwords did not match")
t.Fail()
}
})
}
}