-
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.
- Loading branch information
1 parent
fdcdce6
commit c7baa97
Showing
7 changed files
with
99 additions
and
39 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 |
---|---|---|
@@ -1,7 +1,10 @@ | ||
package commands | ||
package commands_test | ||
|
||
import "testing" | ||
import ( | ||
"hudson-newey/2rm/src/commands" | ||
"testing" | ||
) | ||
|
||
func TestCommandsEcho(t *testing.T) { | ||
Execute("echo 'Hello World'") | ||
commands.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 |
---|---|---|
@@ -1,55 +1,102 @@ | ||
package models | ||
package models_test | ||
|
||
import "testing" | ||
import ( | ||
"hudson-newey/2rm/src/config" | ||
"hudson-newey/2rm/src/models" | ||
"path/filepath" | ||
"testing" | ||
) | ||
|
||
func loadConfig(path string) models.Config { | ||
testConfigDir := "../../tests/assets/configs/" | ||
absolutePath, _ := filepath.Abs(testConfigDir + path) | ||
return config.ParseConfig(absolutePath) | ||
} | ||
|
||
func TestShouldHardDelete(t *testing.T) { | ||
t.Fatal("This test needs to be implemented!") | ||
testedConfig := loadConfig("valid.yml") | ||
|
||
expected := true | ||
realized := testedConfig.ShouldHardDelete("node_modules/") | ||
|
||
if expected != realized { | ||
t.Fatalf("Expected %v but got %v", expected, realized) | ||
} | ||
} | ||
|
||
func TestShouldHardDeleteFalse(t *testing.T) { | ||
t.Fatal("This test needs to be implemented!") | ||
func TestShouldNotHardDelete(t *testing.T) { | ||
testedConfig := loadConfig("valid.yml") | ||
|
||
expected := false | ||
realized := testedConfig.ShouldHardDelete("src/") | ||
|
||
if expected != realized { | ||
t.Fatalf("Expected %v but got %v", expected, realized) | ||
} | ||
} | ||
|
||
func TestShouldHardDeleteEmpty(t *testing.T) { | ||
t.Fatal("This test needs to be implemented!") | ||
testedConfig := loadConfig("only_backups.yml") | ||
|
||
expected := false | ||
realized := testedConfig.ShouldHardDelete("node_modules/") | ||
|
||
if expected != realized { | ||
t.Fatalf("Expected %v but got %v", expected, realized) | ||
} | ||
} | ||
|
||
func TestShouldSoftDelete(t *testing.T) { | ||
t.Fatal("This test needs to be implemented!") | ||
testedConfig := loadConfig("valid.yml") | ||
|
||
expected := true | ||
realized := testedConfig.ShouldSoftDelete("file.bak") | ||
|
||
if expected != realized { | ||
t.Fatalf("Expected %v but got %v", expected, realized) | ||
} | ||
} | ||
|
||
func TestShouldSoftDeleteFalse(t *testing.T) { | ||
t.Fatal("This test needs to be implemented!") | ||
func TestShouldNotSoftDelete(t *testing.T) { | ||
testedConfig := loadConfig("valid.yml") | ||
|
||
expected := false | ||
realized := testedConfig.ShouldSoftDelete("file.txt") | ||
|
||
if expected != realized { | ||
t.Fatalf("Expected %v but got %v", expected, realized) | ||
} | ||
} | ||
|
||
func TestShouldSoftDeleteEmpty(t *testing.T) { | ||
t.Fatal("This test needs to be implemented!") | ||
} | ||
testedConfig := loadConfig("only_backups.yml") | ||
|
||
func TestSoftDeleteDir(t *testing.T) { | ||
t.Fatal("This test needs to be implemented!") | ||
} | ||
expected := false | ||
realized := testedConfig.ShouldSoftDelete("file.bak") | ||
|
||
func TestSoftDeleteDirDefault(t *testing.T) { | ||
t.Fatal("This test needs to be implemented!") | ||
if expected != realized { | ||
t.Fatalf("Expected %v but got %v", expected, realized) | ||
} | ||
} | ||
|
||
func TestMatchesPatternFile(t *testing.T) { | ||
t.Fatal("This test needs to be implemented!") | ||
} | ||
func TestHardMatchesAbsolutePath(t *testing.T) { | ||
testedConfig := loadConfig("abs_path.yml") | ||
|
||
func TestMatchesPatternDirectory(t *testing.T) { | ||
t.Fatal("This test needs to be implemented!") | ||
} | ||
expected := true | ||
realized := testedConfig.ShouldHardDelete("/tmp/2rm/") | ||
|
||
func TestMatchesPatternGlobPostfix(t *testing.T) { | ||
t.Fatal("This test needs to be implemented!") | ||
if expected != realized { | ||
t.Fatalf("Expected %v but got %v", expected, realized) | ||
} | ||
} | ||
|
||
func TestMatchesPatternGlobPrefix(t *testing.T) { | ||
t.Fatal("This test needs to be implemented!") | ||
} | ||
func TestSoftMatchesAbsolutePath(t *testing.T) { | ||
testedConfig := loadConfig("abs_path.yml") | ||
|
||
expected := true | ||
realized := testedConfig.ShouldSoftDelete("/home/john-doe/.local/share/2rm/config.yml") | ||
|
||
func TestMatchesAbsolutePath(t *testing.T) { | ||
t.Fatal("This test needs to be implemented!") | ||
if expected != realized { | ||
t.Fatalf("Expected %v but got %v", expected, realized) | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
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,4 @@ | ||
hard: | ||
- "/tmp/2rm/" | ||
soft: | ||
- "/home/john-doe/.local/share/2rm/config.yml" |
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,3 @@ | ||
soft: | ||
- "*.bak" | ||
- "backups/" |