Skip to content

Commit

Permalink
Test common files are generated or not
Browse files Browse the repository at this point in the history
  • Loading branch information
tcnksm committed Oct 8, 2015
1 parent a2df86f commit 232da79
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 0 deletions.
12 changes: 12 additions & 0 deletions tests/command_framework_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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)
}
Expand Down
12 changes: 12 additions & 0 deletions tests/design_flow_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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)
}
Expand Down
12 changes: 12 additions & 0 deletions tests/flag_framework_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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)
}
Expand Down
5 changes: 5 additions & 0 deletions tests/helper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 232da79

Please sign in to comment.