-
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.
Merge pull request #17 from reecetech/feature/layer-should-process-te…
…st-cases (feat): Add test cases for layer.ShouldProcess()
- Loading branch information
Showing
14 changed files
with
633 additions
and
7 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
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,45 @@ | ||
package layer | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/reecetech/ebs-bootstrap/internal/config" | ||
"github.com/reecetech/ebs-bootstrap/internal/utils" | ||
) | ||
|
||
func TestActivateLogicalVolumeLayerShouldProcess(t *testing.T) { | ||
subtests := []struct { | ||
Name string | ||
Config *config.Config | ||
ExpectedValue bool | ||
}{ | ||
{ | ||
Name: "At Least Once Device Has Lvm Specified", | ||
Config: &config.Config{ | ||
Devices: map[string]config.Device{ | ||
"/dev/xvdb": { | ||
Lvm: "lvm-id", | ||
}, | ||
"/dev/xvdf": {}, | ||
}, | ||
}, | ||
ExpectedValue: true, | ||
}, | ||
{ | ||
Name: "No Device Has Lvm Specified", | ||
Config: &config.Config{ | ||
Devices: map[string]config.Device{ | ||
"/dev/xvdf": {}, | ||
}, | ||
}, | ||
ExpectedValue: false, | ||
}, | ||
} | ||
for _, subtest := range subtests { | ||
t.Run(subtest.Name, func(t *testing.T) { | ||
alvl := NewActivateLogicalVolumeLayer(nil) | ||
output := alvl.ShouldProcess(subtest.Config) | ||
utils.CheckOutput("alvl.ShouldProcess()", t, subtest.ExpectedValue, output) | ||
}) | ||
} | ||
} |
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,59 @@ | ||
package layer | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/reecetech/ebs-bootstrap/internal/config" | ||
"github.com/reecetech/ebs-bootstrap/internal/utils" | ||
) | ||
|
||
func TestResizeLogicalVolumeLayerShouldProcess(t *testing.T) { | ||
subtests := []struct { | ||
Name string | ||
Config *config.Config | ||
ExpectedValue bool | ||
}{ | ||
{ | ||
Name: "At Least Once Device Has Lvm Specified and Resize Enabled", | ||
Config: &config.Config{ | ||
Devices: map[string]config.Device{ | ||
"/dev/xvdb": { | ||
Lvm: "lvm-id", | ||
Options: config.Options{ | ||
Resize: true, | ||
}, | ||
}, | ||
"/dev/xvdf": {}, | ||
}, | ||
}, | ||
ExpectedValue: true, | ||
}, | ||
{ | ||
Name: "Device Has Lvm Specified, but Resize Disabled", | ||
Config: &config.Config{ | ||
Devices: map[string]config.Device{ | ||
"/dev/xvdb": { | ||
Lvm: "lvm-id", | ||
}, | ||
}, | ||
}, | ||
ExpectedValue: false, | ||
}, | ||
{ | ||
Name: "No Device Has Lvm Specified", | ||
Config: &config.Config{ | ||
Devices: map[string]config.Device{ | ||
"/dev/xvdf": {}, | ||
}, | ||
}, | ||
ExpectedValue: false, | ||
}, | ||
} | ||
for _, subtest := range subtests { | ||
t.Run(subtest.Name, func(t *testing.T) { | ||
rlvl := NewResizeLogicalVolumeLayer(nil) | ||
output := rlvl.ShouldProcess(subtest.Config) | ||
utils.CheckOutput("rlvl.ShouldProcess()", t, subtest.ExpectedValue, output) | ||
}) | ||
} | ||
} |
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,45 @@ | ||
package layer | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/reecetech/ebs-bootstrap/internal/config" | ||
"github.com/reecetech/ebs-bootstrap/internal/utils" | ||
) | ||
|
||
func TestCreateLogicalVolumeLayerShouldProcess(t *testing.T) { | ||
subtests := []struct { | ||
Name string | ||
Config *config.Config | ||
ExpectedValue bool | ||
}{ | ||
{ | ||
Name: "At Least Once Device Has Lvm Specified", | ||
Config: &config.Config{ | ||
Devices: map[string]config.Device{ | ||
"/dev/xvdb": { | ||
Lvm: "lvm-id", | ||
}, | ||
"/dev/xvdf": {}, | ||
}, | ||
}, | ||
ExpectedValue: true, | ||
}, | ||
{ | ||
Name: "No Device Has Lvm Specified", | ||
Config: &config.Config{ | ||
Devices: map[string]config.Device{ | ||
"/dev/xvdf": {}, | ||
}, | ||
}, | ||
ExpectedValue: false, | ||
}, | ||
} | ||
for _, subtest := range subtests { | ||
t.Run(subtest.Name, func(t *testing.T) { | ||
clvl := NewCreateLogicalVolumeLayer(nil) | ||
output := clvl.ShouldProcess(subtest.Config) | ||
utils.CheckOutput("clvl.ShouldProcess()", t, subtest.ExpectedValue, output) | ||
}) | ||
} | ||
} |
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
Oops, something went wrong.