diff --git a/tests/command_framework_test.go b/tests/command_framework_test.go index f9557c4..b92ec71 100644 --- a/tests/command_framework_test.go +++ b/tests/command_framework_test.go @@ -5,10 +5,13 @@ import ( "fmt" "os" "os/exec" + "path/filepath" "strconv" "strings" "testing" "time" + + "github.com/tcnksm/gcli/skeleton" ) func TestNew_command_frameworks(t *testing.T) { @@ -63,6 +66,15 @@ func TestNew_command_frameworks(t *testing.T) { t.Fatalf("[%s] expect %q to contain %q", tt.framework, output, expect) } + // Check common files are generated + for _, tmpl := range skeleton.CommonTemplates { + // NOTE: OutputPathTmpl of common template is same as final output name + // and not changed by templating + if _, err := os.Stat(filepath.Join(artifactBin, tmpl.OutputPathTmpl)); os.IsNotExist(err) { + t.Fatalf("file is not exist: %s", tmpl.OutputPathTmpl) + } + } + if err := goTests(artifactBin); err != nil { t.Fatal(err) } diff --git a/tests/design_flow_test.go b/tests/design_flow_test.go index 8b04c66..347e14a 100644 --- a/tests/design_flow_test.go +++ b/tests/design_flow_test.go @@ -3,10 +3,13 @@ package main import ( "fmt" "os" + "path/filepath" "strconv" "strings" "testing" "time" + + "github.com/tcnksm/gcli/skeleton" ) func TestDesignFlow(t *testing.T) { @@ -71,6 +74,15 @@ func TestDesignFlow(t *testing.T) { t.Fatalf("Expect %q to contain %q", output, expect) } + // Check common files are generated + for _, tmpl := range skeleton.CommonTemplates { + // NOTE: OutputPathTmpl of common template is same as final output name + // and not changed by templating + if _, err := os.Stat(filepath.Join(artifactBin, tmpl.OutputPathTmpl)); os.IsNotExist(err) { + t.Fatalf("file is not exist: %s", tmpl.OutputPathTmpl) + } + } + if err := goTests(artifactBin); err != nil { t.Fatalf("Failed to run go tests in %s: %s", artifactBin, err) } diff --git a/tests/flag_framework_test.go b/tests/flag_framework_test.go index d12cb37..d2f8760 100644 --- a/tests/flag_framework_test.go +++ b/tests/flag_framework_test.go @@ -5,10 +5,13 @@ import ( "fmt" "os" "os/exec" + "path/filepath" "strconv" "strings" "testing" "time" + + "github.com/tcnksm/gcli/skeleton" ) func TestNew_flag_frameworks(t *testing.T) { @@ -52,6 +55,15 @@ func TestNew_flag_frameworks(t *testing.T) { t.Fatalf("[%s] expect %q to contain %q", tt.framework, output, expect) } + // Check common files are generated + for _, tmpl := range skeleton.CommonTemplates { + // NOTE: OutputPathTmpl of common template is same as final output name + // and not changed by templating + if _, err := os.Stat(filepath.Join(artifactBin, tmpl.OutputPathTmpl)); os.IsNotExist(err) { + t.Fatalf("file is not exist: %s", tmpl.OutputPathTmpl) + } + } + if err := goTests(artifactBin); err != nil { t.Fatal(err) } diff --git a/tests/helper_test.go b/tests/helper_test.go index e29cd5d..0321c6f 100644 --- a/tests/helper_test.go +++ b/tests/helper_test.go @@ -87,6 +87,11 @@ func runGcli(args []string) (string, error) { } +func checkFile(files []string) error { + + return nil +} + func goTests(output string) error { // Change directory to artifact directory root if err := os.Chdir(output); err != nil {