fix: inherit App error catalogs on generated routes without local errors
This commit is contained in:
@@ -87,7 +87,7 @@ func TestErrorCatalogConsumer(t *testing.T) {
|
||||
testCatalogConsumer(t, "errors.api", "errorCatalog")
|
||||
}
|
||||
|
||||
func testCatalogConsumer(t *testing.T, apiFile, fixtureName string) {
|
||||
func testCatalogConsumer(t *testing.T, apiFile, fixtureName string, extraFiles ...map[string]string) {
|
||||
t.Helper()
|
||||
if os.Getenv("GO_OMNI_SCAFFOLD_INTEGRATION") == "" {
|
||||
t.Skip("consumer integration")
|
||||
@@ -118,12 +118,24 @@ func testCatalogConsumer(t *testing.T, apiFile, fixtureName string) {
|
||||
}
|
||||
generate(false)
|
||||
|
||||
fixture := readFile(t, filepath.Join("testdata", fixtureName, "consumer_test.go"))
|
||||
writeFile(t, filepath.Join(dir, "consumer_test.go"), fixture)
|
||||
files := map[string]string{"consumer_test.go": "consumer_test.go"}
|
||||
for _, extra := range extraFiles {
|
||||
for target, source := range extra {
|
||||
files[target] = source
|
||||
}
|
||||
}
|
||||
before := map[string]string{}
|
||||
for target, source := range files {
|
||||
fixture := readFile(t, filepath.Join("testdata", fixtureName, source))
|
||||
writeFile(t, filepath.Join(dir, target), fixture)
|
||||
before[target] = fixture
|
||||
}
|
||||
generate(false)
|
||||
generate(true)
|
||||
if readFile(t, filepath.Join(dir, "consumer_test.go")) != fixture {
|
||||
t.Fatal("regeneration overwrote manual code")
|
||||
for target, fixture := range before {
|
||||
if readFile(t, filepath.Join(dir, target)) != fixture {
|
||||
t.Fatalf("regeneration overwrote %s", target)
|
||||
}
|
||||
}
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 120*time.Second)
|
||||
defer cancel()
|
||||
|
||||
Reference in New Issue
Block a user