-
-
Notifications
You must be signed in to change notification settings - Fork 1
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
2 changed files
with
36 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package main | ||
|
||
import ( | ||
"encoding/json" | ||
"testing" | ||
|
||
"github.com/vanilla-os/vib/api" | ||
) | ||
|
||
type testCases struct { | ||
module interface{} | ||
expected string | ||
} | ||
|
||
// This slice is most likely the only thing that needs to be modified | ||
// It should be filled with the cases that the function should run through | ||
// it consists of the module that should be passed and the output that should result from the module | ||
var test = []testCases{ | ||
{ExampleModule{Name: "Case Descrition", Type: "PluginName", Source: api.Source{Type: "tar"}}, "expected result here"}, | ||
} | ||
|
||
// Simply run through all the test cases defined above | ||
func TestBuildModule(t *testing.T) { | ||
for _, testCase := range test { | ||
moduleInterface, err := json.Marshal(testCase.module) | ||
if err != nil { | ||
t.Errorf("Error in json %s", err.Error()) | ||
} | ||
if output := BuildModule(convertToCString(string(moduleInterface)), convertToCString("")); convertToGoString(output) != testCase.expected { | ||
t.Errorf("Output %s not equivalent to expected %s", convertToGoString(output), testCase.expected) | ||
} | ||
} | ||
|
||
} |