test: add integration test for 'gas init'
This commit is contained in:
parent
a81dfb69a5
commit
2146e1de77
@ -1,6 +1,7 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"bufio"
|
||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
@ -32,8 +33,9 @@ var cmd_init = &cobra.Command{
|
|||||||
// Get all the config values
|
// Get all the config values
|
||||||
get_val := func(prompt string, val *string) {
|
get_val := func(prompt string, val *string) {
|
||||||
fmt.Printf("%s (%q): ", prompt, *val)
|
fmt.Printf("%s (%q): ", prompt, *val)
|
||||||
input := ""
|
scanner := bufio.NewScanner(os.Stdin)
|
||||||
Must(fmt.Scanln(&input))
|
scanner.Scan()
|
||||||
|
input := scanner.Text()
|
||||||
if input != "" {
|
if input != "" {
|
||||||
*val = input
|
*val = input
|
||||||
}
|
}
|
||||||
|
|||||||
31
ops/gas_init_test.sh
Executable file
31
ops/gas_init_test.sh
Executable file
@ -0,0 +1,31 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# ------------------
|
||||||
|
# This is a test script that initializes a new project.
|
||||||
|
# ------------------
|
||||||
|
|
||||||
|
|
||||||
|
set -e
|
||||||
|
set -x
|
||||||
|
|
||||||
|
PS4='+(${BASH_SOURCE}:${LINENO}): '
|
||||||
|
cd "$(dirname "${BASH_SOURCE[0]}")/.."
|
||||||
|
|
||||||
|
# Compile `gas`
|
||||||
|
gas="/tmp/gas"
|
||||||
|
go build -o $gas ./cmd
|
||||||
|
|
||||||
|
test_project="/memory/test_gasproj"
|
||||||
|
if [[ -e $test_project ]]; then
|
||||||
|
rm -r "$test_project"
|
||||||
|
fi
|
||||||
|
|
||||||
|
$gas init "$test_project" <<EOF
|
||||||
|
mymodule
|
||||||
|
mydb.db
|
||||||
|
prog
|
||||||
|
EOF
|
||||||
|
|
||||||
|
|
||||||
|
# Notify success in green
|
||||||
|
echo -e "\033[32mAll tests passed. Finished successfully.\033[0m"
|
||||||
Loading…
x
Reference in New Issue
Block a user