-
Notifications
You must be signed in to change notification settings - Fork 56
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
style: Only run spec generation in dev/test
Previously it could have run if the binary was run from any directory which contains a `docs` or `.git` directory.
- Loading branch information
Showing
5 changed files
with
42 additions
and
88 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
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 |
---|---|---|
@@ -1,25 +1,20 @@ | ||
package server | ||
|
||
import ( | ||
"os" | ||
"strings" | ||
"testing" | ||
|
||
"github.com/stretchr/testify/require" | ||
) | ||
|
||
func TestOpenAPIGen(t *testing.T) { | ||
// must run from infra root dir | ||
wd, err := os.Getwd() | ||
require.NoError(t, err) | ||
|
||
parts := strings.Split(wd, string(os.PathSeparator)) | ||
|
||
if parts[len(parts)-1] != "infra" { | ||
err := os.Chdir("../..") | ||
require.NoError(t, err) | ||
} | ||
|
||
s := &Server{} | ||
// TestWriteOpenAPISpec is not really a test. It's a way of ensuring the openapi | ||
// spec is updated. | ||
// TODO: replace this with a test that uses golden, and a CI check to make sure the | ||
// file in git matches the source code. | ||
func TestWriteOpenAPISpec(t *testing.T) { | ||
s := Server{} | ||
s.GenerateRoutes() | ||
|
||
filename := "../../docs/api/openapi3.json" | ||
err := writeOpenAPISpecToFile(filename) | ||
require.NoError(t, err) | ||
} |
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