-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Change request directory and add test.PathToDir
Signed-off-by: Oğuzhan Durgun <[email protected]>
- Loading branch information
1 parent
cd64941
commit 6343e83
Showing
6 changed files
with
60 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
// Copyright 2021-2023 Zenauth Ltd. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
package module_test | ||
|
||
import ( | ||
"bytes" | ||
"os" | ||
"testing" | ||
|
||
pgs "github.com/lyft/protoc-gen-star/v2" | ||
"github.com/stretchr/testify/require" | ||
|
||
"github.com/cerbos/protoc-gen-jsonschema/internal/common" | ||
"github.com/cerbos/protoc-gen-jsonschema/internal/module" | ||
"github.com/cerbos/protoc-gen-jsonschema/internal/test" | ||
) | ||
|
||
const requestName = "code_generator_request.pb.bin" | ||
|
||
func TestModule(t *testing.T) { | ||
reqFile, err := os.Open(test.PathToDir(t, requestName)) | ||
require.NoError(t, err) | ||
resBytes := &bytes.Buffer{} | ||
pgs.Init( | ||
pgs.DebugEnv(common.DebugEnv), | ||
pgs.ProtocInput(reqFile), | ||
pgs.ProtocOutput(resBytes), | ||
).RegisterModule(module.New()).Render() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
// Copyright 2021-2023 Zenauth Ltd. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
package test | ||
|
||
import ( | ||
"path/filepath" | ||
"runtime" | ||
"testing" | ||
) | ||
|
||
func PathToDir(tb testing.TB, dir string) string { | ||
tb.Helper() | ||
|
||
_, currFile, _, ok := runtime.Caller(0) | ||
if !ok { | ||
tb.Error("Failed to detect testdata directory") | ||
return "" | ||
} | ||
|
||
return filepath.Join(filepath.Dir(currFile), "testdata", dir) | ||
} |
Binary file renamed
BIN
+231 KB
internal/test/code_generator_request.pb.bin → ...st/testdata/code_generator_request.pb.bin
Binary file not shown.