-
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.
Bug fixing new storage initialization
- Loading branch information
Showing
11 changed files
with
164 additions
and
38 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
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,73 @@ | ||
package main | ||
|
||
import ( | ||
"fmt" | ||
"os" | ||
"os/exec" | ||
"path/filepath" | ||
"strings" | ||
|
||
"testing" | ||
) | ||
|
||
const ( | ||
CRYPTARCH_BINARY_DIR = "dist" // Directory the executable is in. | ||
CRYPTARCH_BINARY_NAME = "cryptarch" // Name of the Cryptarch binary. | ||
) | ||
|
||
var ( | ||
// Filepath for the Cryptarch executable. | ||
cryptarch = filepath.Join(CRYPTARCH_BINARY_DIR, CRYPTARCH_BINARY_NAME) | ||
// Environment to execute Cryptarch with, appended to `os.Environ()`. | ||
testEnviron = map[string]string{ | ||
"GOCOVERDIR": ".coverdata", | ||
} | ||
) | ||
|
||
// Converts a string-to-string mapping to a comma-delimited string. | ||
func environToA(environ map[string]string, delimiter string) (a string) { | ||
for k, v := range environ { | ||
a += fmt.Sprintf("%s=\"%s\"%s", k, v, delimiter) | ||
} | ||
|
||
// Take the last delimiter off. | ||
return strings.TrimSuffix(a, delimiter) | ||
} | ||
|
||
// Executes the Cryptarch binary. | ||
func runCryptarch(args []string) ([]byte, error) { | ||
var ( | ||
environ = append(os.Environ(), environToA(testEnviron, ",")) | ||
) | ||
|
||
cmd := exec.Command(cryptarch, args...) | ||
fmt.Printf("Executing: %v ... \n", cmd) | ||
cmd.Env = environ | ||
return cmd.CombinedOutput() | ||
} | ||
|
||
// Test set-up. | ||
func TestMain(m *testing.M) { | ||
os.Exit(m.Run()) | ||
} | ||
|
||
// Run CLI invocation tests. | ||
func TestCLI(t *testing.T) { | ||
cliTests := []struct { | ||
testName string | ||
cliArgs []string | ||
}{ | ||
{"no-args", []string{}}, | ||
{"help", []string{"-h"}}, | ||
} | ||
|
||
for _, cliTest := range cliTests { | ||
t.Run(cliTest.testName, func(t *testing.T) { | ||
_, err := runCryptarch(cliTest.cliArgs) | ||
|
||
if err != nil { | ||
t.Error(err) | ||
} | ||
}) | ||
} | ||
} |
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