Skip to content

Commit

Permalink
Add TestCreateFileFailures for more coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
dolmen committed Mar 28, 2024
1 parent 001f737 commit 35c9aa3
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions codegen_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package codegen_test
import (
"log"
"os"
"strings"
"testing"

"github.com/dolmen-go/codegen"
Expand Down Expand Up @@ -46,3 +47,10 @@ func TestParseFailures(t *testing.T) {
t.Fatal("MustParse should panic.")
}
}

func TestCreateFileFailures(t *testing.T) {
err := codegen.CreateFile("tmp_test.go", codegen.MustParse("package main_test\n").Template, 0)
if err == nil || !strings.Contains(err.Error(), "https://golang.org/s/generatedcode") {
t.Fatal("Error expected")
}
}

0 comments on commit 35c9aa3

Please sign in to comment.