-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add config parse tests and --help passthrough
- Loading branch information
1 parent
a48a03d
commit fdcdce6
Showing
15 changed files
with
208 additions
and
5 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
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,7 @@ | ||
package commands | ||
|
||
import "testing" | ||
|
||
func TestCommandsEcho(t *testing.T) { | ||
Execute("echo 'Hello World'") | ||
} |
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,73 @@ | ||
package config | ||
|
||
import ( | ||
"hudson-newey/2rm/src/models" | ||
"path/filepath" | ||
"reflect" | ||
"testing" | ||
) | ||
|
||
func assertConfig(t *testing.T, configPath string, expectedConfig models.Config) { | ||
testConfigDir := "../../tests/assets/configs/" | ||
absolutePath, err := filepath.Abs(testConfigDir + configPath) | ||
if err != nil { | ||
t.Errorf("Failed to get absolute path") | ||
} | ||
|
||
realizedConfig := ParseConfig(absolutePath) | ||
|
||
if !reflect.DeepEqual(expectedConfig, realizedConfig) { | ||
t.Errorf("Expected %v but got %v", expectedConfig, realizedConfig) | ||
} | ||
} | ||
|
||
func TestParsingConfig(t *testing.T) { | ||
expectedConfig := models.Config{ | ||
Backups: "/tmp/2rm/", | ||
Hard: []string{ | ||
"node_modules/", | ||
"target/", | ||
".angular/", | ||
".next/", | ||
}, | ||
Soft: []string{ | ||
"*.bak", | ||
}, | ||
} | ||
|
||
assertConfig(t, "valid.yml", expectedConfig) | ||
} | ||
|
||
// this test asserts that we can parse a partial config | ||
// we do not have to check every combination of partial configs | ||
// because that would result in a massive explosion of tests | ||
// that would not provide much value | ||
func TestOnlyHardConfig(t *testing.T) { | ||
expectedConfig := models.Config{ | ||
Hard: []string{ | ||
"node_modules/", | ||
"target/", | ||
".angular/", | ||
".next/", | ||
}, | ||
} | ||
|
||
assertConfig(t, "only_hard.yml", expectedConfig) | ||
} | ||
|
||
func TestOnlyBackups(t *testing.T) { | ||
expectedConfig := models.Config{ | ||
Backups: "/tmp/2rm/", | ||
} | ||
assertConfig(t, "only_backups.yml", expectedConfig) | ||
} | ||
|
||
func TestParsingEmptyConfig(t *testing.T) { | ||
expectedConfig := models.Config{} | ||
assertConfig(t, "empty.yml", expectedConfig) | ||
} | ||
|
||
func TestParsingConfigWithMissingFile(t *testing.T) { | ||
expectedConfig := models.Config{} | ||
assertConfig(t, "missing.yml", expectedConfig) | ||
} |
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,55 @@ | ||
package models | ||
|
||
import "testing" | ||
|
||
func TestShouldHardDelete(t *testing.T) { | ||
t.Fatal("This test needs to be implemented!") | ||
} | ||
|
||
func TestShouldHardDeleteFalse(t *testing.T) { | ||
t.Fatal("This test needs to be implemented!") | ||
} | ||
|
||
func TestShouldHardDeleteEmpty(t *testing.T) { | ||
t.Fatal("This test needs to be implemented!") | ||
} | ||
|
||
func TestShouldSoftDelete(t *testing.T) { | ||
t.Fatal("This test needs to be implemented!") | ||
} | ||
|
||
func TestShouldSoftDeleteFalse(t *testing.T) { | ||
t.Fatal("This test needs to be implemented!") | ||
} | ||
|
||
func TestShouldSoftDeleteEmpty(t *testing.T) { | ||
t.Fatal("This test needs to be implemented!") | ||
} | ||
|
||
func TestSoftDeleteDir(t *testing.T) { | ||
t.Fatal("This test needs to be implemented!") | ||
} | ||
|
||
func TestSoftDeleteDirDefault(t *testing.T) { | ||
t.Fatal("This test needs to be implemented!") | ||
} | ||
|
||
func TestMatchesPatternFile(t *testing.T) { | ||
t.Fatal("This test needs to be implemented!") | ||
} | ||
|
||
func TestMatchesPatternDirectory(t *testing.T) { | ||
t.Fatal("This test needs to be implemented!") | ||
} | ||
|
||
func TestMatchesPatternGlobPostfix(t *testing.T) { | ||
t.Fatal("This test needs to be implemented!") | ||
} | ||
|
||
func TestMatchesPatternGlobPrefix(t *testing.T) { | ||
t.Fatal("This test needs to be implemented!") | ||
} | ||
|
||
func TestMatchesAbsolutePath(t *testing.T) { | ||
t.Fatal("This test needs to be implemented!") | ||
} |
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 @@ | ||
package patches |
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,12 +1,11 @@ | ||
package util | ||
|
||
func InArray[T comparable](arr []T, query T) bool { | ||
for _, value := range(arr) { | ||
if (value == query) { | ||
for _, value := range arr { | ||
if value == query { | ||
return true | ||
} | ||
} | ||
|
||
return false | ||
} | ||
|
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,21 @@ | ||
package util | ||
|
||
import "testing" | ||
|
||
func TestInArrayTrue(t *testing.T) { | ||
expectedResult := true | ||
realizedResult := InArray([]int{1, 2, 3}, 1) | ||
|
||
if realizedResult != expectedResult { | ||
t.Fatalf("Expected %v but got %v", expectedResult, realizedResult) | ||
} | ||
} | ||
|
||
func TestInArrayFalse(t *testing.T) { | ||
expectedResult := false | ||
realizedResult := InArray([]int{1, 2, 3}, 4) | ||
|
||
if realizedResult != expectedResult { | ||
t.Fatalf("Expected %v but got %v", expectedResult, realizedResult) | ||
} | ||
} |
Empty file.
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 @@ | ||
backups: /tmp/2rm/ |
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,5 @@ | ||
hard: | ||
- node_modules/ | ||
- target/ | ||
- .angular/ | ||
- .next/ |
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 @@ | ||
This directory contains the configs that we use in tests |
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,8 @@ | ||
backups: /tmp/2rm/ | ||
hard: | ||
- node_modules/ | ||
- target/ | ||
- .angular/ | ||
- .next/ | ||
soft: | ||
- "*.bak" |