Skip to content

Commit

Permalink
fix: introduced require lib to test
Browse files Browse the repository at this point in the history
Signed-off-by: Fritz Duchardt <[email protected]>
  • Loading branch information
fritzduchardt committed Nov 12, 2023
1 parent 02668ff commit 6ec4c25
Showing 1 changed file with 6 additions and 20 deletions.
26 changes: 6 additions & 20 deletions test/e2e/directory_flag_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
package e2e

import (
"github.com/stretchr/testify/require"
"os"
"testing"
)
Expand All @@ -18,25 +19,12 @@ func TestUseDirectory(t *testing.T) {
reset := func() {
// Make sure state is reset
_, err := vendir.RunWithOpts([]string{"sync"}, RunOpts{Dir: path})
if err != nil {
t.Fatalf("Expected no err")
}
require.NoError(t, err)
}
checkFileContent := func(filePath string, expectedContent string) {
file, err := os.ReadFile(path + filePath)
if err != nil {
t.Fatalf("Expected no err")
}
if string(file) != expectedContent {
t.Fatalf("Expected file contents to be known: %s", string(file))
}
}

checkFileExists := func(filePath string) {
_, err := os.Stat(path + filePath)
if err != nil {
t.Fatalf("Expected no err")
}
require.NoError(t, err)
require.EqualValues(t, string(file), expectedContent)
}

// Sync with directory flag
Expand All @@ -49,13 +37,11 @@ func TestUseDirectory(t *testing.T) {

// Sync with directory flag and local-dir-dev
_, err = vendir.RunWithOpts([]string{"sync", "--directory", "vendor/local-dir=local-dir-dev"}, RunOpts{Dir: path})
if err != nil {
t.Fatalf("Expected no err")
}
require.NoError(t, err)
checkFileContent("/vendor/local-dir/file.txt", "file-dir-dev\n")

// Lock file check
checkFileExists("/vendir.lock.yml")
require.FileExists(t, path+"/vendir.lock.yml")

// Final regular sync to make sure nothing in vendir was deleted (manual syncs would fail).
reset()
Expand Down

0 comments on commit 6ec4c25

Please sign in to comment.