-
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
83 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package main | ||
|
||
import ( | ||
"fmt" | ||
"testing" | ||
|
||
"github.com/oalders/is/ops" | ||
"github.com/oalders/is/types" | ||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
func TestArchCmd(t *testing.T) { | ||
t.Parallel() | ||
type ArchTest struct { | ||
Cmd ArchCmd | ||
Error bool | ||
Success bool | ||
} | ||
|
||
tests := []ArchTest{ | ||
{ArchCmd{ops.Eq, "zzz"}, false, false}, | ||
{ArchCmd{ops.Ne, "zzz"}, false, true}, | ||
{ArchCmd{ops.Like, "zzz"}, false, false}, | ||
{ArchCmd{ops.Unlike, "zzz"}, false, true}, | ||
} | ||
|
||
for _, test := range tests { | ||
ctx := types.Context{Debug: false} | ||
err := test.Cmd.Run(&ctx) | ||
name := fmt.Sprintf("%s %s", test.Cmd.Op, test.Cmd.Val) | ||
if test.Error { | ||
assert.Error(t, err, name) | ||
} else { | ||
assert.NoError(t, err, name) | ||
} | ||
if test.Success { | ||
assert.True(t, ctx.Success, name) | ||
} else { | ||
assert.False(t, ctx.Success, name) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
#!/usr/bin/env bats | ||
|
||
bats_require_minimum_version 1.5.0 | ||
|
||
@test "is arch ne xxx" { | ||
./is arch ne xxx | ||
} | ||
|
||
@test "is arch unlike xxx" { | ||
./is arch unlike xxx | ||
} | ||
|
||
@test 'is arch like ".*"' { | ||
./is arch like ".*" | ||
} | ||
|
||
@test 'is arch eq beos' { | ||
run ! ./is arch eq beos | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,20 @@ | ||
#!/usr/bin/env bats | ||
|
||
@test "is known cli" { | ||
./is known cli version tmux | ||
./is known cli version tmux | ||
} | ||
|
||
@test "is known os" { | ||
./is known os name | ||
./is known os name | ||
} | ||
|
||
@test "is known arch" { | ||
./is known arch | ||
} | ||
|
||
bats_require_minimum_version 1.5.0 | ||
|
||
@test "ensure something is printed" { | ||
run -0 ./is known arch | ||
[ -n "${lines[0]}" ] | ||
} |