|
| 1 | +package e2e |
| 2 | + |
| 3 | +import ( |
| 4 | + "fmt" |
| 5 | + "github.com/gopher-fleece/gleece/definitions" |
| 6 | + . "github.com/onsi/ginkgo/v2" |
| 7 | + . "github.com/onsi/gomega" |
| 8 | + "os" |
| 9 | +) |
| 10 | + |
| 11 | +var _ = Describe("E2E Generated Date Comment Test", func() { |
| 12 | + Context("When skipGenerateDateComment is true", func() { |
| 13 | + It("Should not include 'Generated Date: ' in generated files", func() { |
| 14 | + |
| 15 | + for _, engine := range definitions.SupportedRoutingEngineStrings { |
| 16 | + filePath := fmt.Sprintf("./%s/routes/%s.e2e.gleece.go", engine, engine) |
| 17 | + |
| 18 | + // Read the generated file |
| 19 | + content, err := os.ReadFile(filePath) |
| 20 | + Expect(err).ToNot(HaveOccurred(), "Failed to read generated file: "+filePath) |
| 21 | + |
| 22 | + // Convert content to string and check for "Generated Date: " |
| 23 | + fileContent := string(content) |
| 24 | + |
| 25 | + // Verify the file content doesn't contain "Generated Date: " |
| 26 | + Expect(fileContent).ToNot(ContainSubstring("Generated Date: "), |
| 27 | + "Generated file should not contain 'Generated Date: ' when skipGenerateDateComment is true: "+filePath) |
| 28 | + |
| 29 | + // Verify the file was generated correctly (just a sanity check) |
| 30 | + Expect(fileContent).To(ContainSubstring("This file is automatically generated"), |
| 31 | + "Generated file should contain the standard header: "+filePath) |
| 32 | + } |
| 33 | + }) |
| 34 | + |
| 35 | + It("Should include 'Generated Date: ' in ex feature generated files", func() { |
| 36 | + |
| 37 | + for _, engine := range definitions.SupportedRoutingEngineStrings { |
| 38 | + filePath := fmt.Sprintf("./%s/ex_extra_routes/%s.e2e.ex_extra.gleece.go", engine, engine) |
| 39 | + |
| 40 | + // Read the generated file |
| 41 | + content, err := os.ReadFile(filePath) |
| 42 | + Expect(err).ToNot(HaveOccurred(), "Failed to read generated file: "+filePath) |
| 43 | + |
| 44 | + // Convert content to string and check for "Generated Date: " |
| 45 | + fileContent := string(content) |
| 46 | + |
| 47 | + // Verify the file content doesn't contain "Generated Date: " |
| 48 | + Expect(fileContent).To(ContainSubstring("Generated Date: "), |
| 49 | + "Generated file should not contain 'Generated Date: ' when skipGenerateDateComment is true: "+filePath) |
| 50 | + |
| 51 | + // Verify the file was generated correctly (just a sanity check) |
| 52 | + Expect(fileContent).To(ContainSubstring("This file is automatically generated"), |
| 53 | + "Generated file should contain the standard header: "+filePath) |
| 54 | + } |
| 55 | + }) |
| 56 | + |
| 57 | + }) |
| 58 | +}) |
0 commit comments