|
72 | 72 | } |
73 | 73 | ) |
74 | 74 |
|
| 75 | +func TestCodecError(t *testing.T) { |
| 76 | + outDir := t.TempDir() |
| 77 | + goodConfig := &config.Config{ |
| 78 | + General: config.GeneralConfig{ |
| 79 | + SpecificationFormat: "openapi", |
| 80 | + ServiceConfig: path.Join(testdataDir, "googleapis/google/cloud/secretmanager/v1/secretmanager_v1.yaml"), |
| 81 | + SpecificationSource: path.Join(testdataDir, "openapi/secretmanager_openapi_v1.json"), |
| 82 | + }, |
| 83 | + } |
| 84 | + errorConfig := &config.Config{ |
| 85 | + General: config.GeneralConfig{ |
| 86 | + SpecificationFormat: "openapi", |
| 87 | + ServiceConfig: path.Join(testdataDir, "googleapis/google/cloud/secretmanager/v1/secretmanager_v1.yaml"), |
| 88 | + SpecificationSource: path.Join(testdataDir, "openapi/secretmanager_openapi_v1.json"), |
| 89 | + }, |
| 90 | + Codec: map[string]string{ |
| 91 | + "--invalid--": "--invalid--", |
| 92 | + }, |
| 93 | + } |
| 94 | + model, err := parser.CreateModel(errorConfig) |
| 95 | + if err != nil { |
| 96 | + t.Fatal(err) |
| 97 | + } |
| 98 | + if err := Generate(model, outDir, errorConfig); err == nil { |
| 99 | + t.Errorf("expected an error with invalid Codec options") |
| 100 | + } |
| 101 | + |
| 102 | + if err := GenerateStorage(outDir, model, errorConfig, model, goodConfig); err == nil { |
| 103 | + t.Errorf("expected an error with invalid Codec options for storage") |
| 104 | + } |
| 105 | + if err := GenerateStorage(outDir, model, goodConfig, model, errorConfig); err == nil { |
| 106 | + t.Errorf("expected an error with invalid Codec options for control") |
| 107 | + } |
| 108 | +} |
| 109 | + |
75 | 110 | func TestRustFromOpenAPI(t *testing.T) { |
76 | 111 | requireProtoc(t) |
77 | 112 | outDir := t.TempDir() |
|
0 commit comments