From 35c9aa3a44337b5b44e39856dfe14c3128ef5c30 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Olivier=20Mengu=C3=A9?= Date: Thu, 28 Mar 2024 01:14:23 +0100 Subject: [PATCH] Add TestCreateFileFailures for more coverage --- codegen_test.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/codegen_test.go b/codegen_test.go index 1a27e01..7694e98 100644 --- a/codegen_test.go +++ b/codegen_test.go @@ -3,6 +3,7 @@ package codegen_test import ( "log" "os" + "strings" "testing" "github.com/dolmen-go/codegen" @@ -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") + } +}