mirror of
https://github.com/grafana/grafana.git
synced 2024-12-30 10:47:30 -06:00
9691af83ee
* Go program to output openapi * Fix number type syntax Resolves error: 'unsupported op for number &' * Render just the schemas * Use args as entrypoints and add test * Update README, tidy go.mod
48 lines
821 B
Go
48 lines
821 B
Go
package main
|
|
|
|
import (
|
|
"encoding/json"
|
|
"testing"
|
|
)
|
|
|
|
func TestOpenAPISchemas(t *testing.T) {
|
|
|
|
tests := map[string]struct {
|
|
entrypoints []string
|
|
}{
|
|
"All packages": {
|
|
entrypoints: []string{"./..."},
|
|
},
|
|
"One package": {
|
|
entrypoints: []string{"./panels"},
|
|
},
|
|
"Many packags": {
|
|
entrypoints: []string{
|
|
"./panels",
|
|
"./targets",
|
|
"./transformations",
|
|
"./variables",
|
|
},
|
|
},
|
|
}
|
|
|
|
for testName, test := range tests {
|
|
|
|
t.Logf("Running test case %s...", testName)
|
|
|
|
j, err := openAPISchemas(test.entrypoints)
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
|
|
// We don't want to validate the JSON content since it's expected to change
|
|
// often. Only that it is valid JSON by unmarshalling it.
|
|
|
|
var iface interface{}
|
|
err = json.Unmarshal(j, &iface)
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
}
|
|
}
|