-
Notifications
You must be signed in to change notification settings - Fork 4
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
6 changed files
with
93 additions
and
9 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,37 @@ | ||
package add | ||
|
||
import ( | ||
"errors" | ||
"io/fs" | ||
"os" | ||
"path/filepath" | ||
"testing" | ||
|
||
"github.com/candrewlee14/webman/utils" | ||
|
||
"github.com/matryer/is" | ||
) | ||
|
||
func TestAdd(t *testing.T) { | ||
if _, ok := os.LookupEnv("WEBMAN_INTEGRATION"); !ok { | ||
t.Skip("skipping integration test") | ||
} | ||
|
||
assert := is.New(t) | ||
|
||
tmp := t.TempDir() | ||
utils.Init(tmp) | ||
os.Args = []string{"webman", "jq", "rg"} | ||
|
||
err := AddCmd.Execute() | ||
assert.NoErr(err) // Command should execute | ||
|
||
_, err = os.Stat(filepath.Join(utils.WebmanBinDir, "jq")) | ||
assert.NoErr(err) // jq binary should exist | ||
|
||
_, err = os.Stat(filepath.Join(utils.WebmanBinDir, "rg")) | ||
assert.NoErr(err) // rg binary should exist | ||
|
||
_, err = os.Stat(filepath.Join(utils.WebmanBinDir, "bat")) | ||
assert.True(errors.Is(err, fs.ErrNotExist)) // bat binary should not exist | ||
} |
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,41 @@ | ||
package remove | ||
|
||
import ( | ||
"errors" | ||
"io/fs" | ||
"os" | ||
"path/filepath" | ||
"testing" | ||
|
||
"github.com/candrewlee14/webman/cmd/add" | ||
"github.com/candrewlee14/webman/utils" | ||
|
||
"github.com/matryer/is" | ||
) | ||
|
||
func TestRemove(t *testing.T) { | ||
if _, ok := os.LookupEnv("WEBMAN_INTEGRATION"); !ok { | ||
t.Skip("skipping integration test") | ||
} | ||
|
||
assert := is.New(t) | ||
|
||
tmp := t.TempDir() | ||
utils.Init(tmp) | ||
os.Args = []string{"webman", "jq"} | ||
|
||
err := add.AddCmd.Execute() | ||
assert.NoErr(err) // Command should execute | ||
|
||
_, err = os.Stat(filepath.Join(utils.WebmanBinDir, "jq")) | ||
assert.NoErr(err) // jq binary should exist | ||
|
||
err = RemoveCmd.Execute() | ||
assert.NoErr(err) // Command should execute | ||
|
||
_, err = os.Stat(filepath.Join(utils.WebmanBinDir, "jq")) | ||
assert.True(errors.Is(err, fs.ErrNotExist)) // jq binary should not exist | ||
|
||
_, err = os.Stat(filepath.Join(utils.WebmanPkgDir, "jq")) | ||
assert.True(errors.Is(err, fs.ErrNotExist)) // jq pkg should not exist | ||
} |
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
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