mirror of https://github.com/k3s-io/k3s
openapi: Remove unused test structure and code.
parent
92db97dfcc
commit
54b9c22f2a
|
@ -36,13 +36,10 @@ go_test(
|
|||
deps = [
|
||||
":go_default_library",
|
||||
"//pkg/kubectl/cmd/util/openapi/testing:go_default_library",
|
||||
"//vendor/github.com/googleapis/gnostic/OpenAPIv2:go_default_library",
|
||||
"//vendor/github.com/googleapis/gnostic/compiler:go_default_library",
|
||||
"//vendor/github.com/onsi/ginkgo:go_default_library",
|
||||
"//vendor/github.com/onsi/ginkgo/config:go_default_library",
|
||||
"//vendor/github.com/onsi/ginkgo/types:go_default_library",
|
||||
"//vendor/github.com/onsi/gomega:go_default_library",
|
||||
"//vendor/gopkg.in/yaml.v2:go_default_library",
|
||||
"//vendor/k8s.io/apimachinery/pkg/runtime/schema:go_default_library",
|
||||
],
|
||||
)
|
||||
|
|
|
@ -18,15 +18,7 @@ package openapi_test
|
|||
|
||||
import (
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"sync"
|
||||
|
||||
"gopkg.in/yaml.v2"
|
||||
|
||||
"github.com/googleapis/gnostic/OpenAPIv2"
|
||||
"github.com/googleapis/gnostic/compiler"
|
||||
. "github.com/onsi/ginkgo"
|
||||
. "github.com/onsi/gomega"
|
||||
|
||||
|
@ -34,68 +26,6 @@ import (
|
|||
tst "k8s.io/kubernetes/pkg/kubectl/cmd/util/openapi/testing"
|
||||
)
|
||||
|
||||
// Test utils
|
||||
var data apiData
|
||||
|
||||
type apiData struct {
|
||||
sync.Once
|
||||
data *openapi_v2.Document
|
||||
err error
|
||||
}
|
||||
|
||||
func (d *apiData) OpenAPISchema() (*openapi_v2.Document, error) {
|
||||
d.Do(func() {
|
||||
// Get the path to the swagger.json file
|
||||
wd, err := os.Getwd()
|
||||
if err != nil {
|
||||
d.err = err
|
||||
return
|
||||
}
|
||||
|
||||
abs, err := filepath.Abs(wd)
|
||||
if err != nil {
|
||||
d.err = err
|
||||
return
|
||||
}
|
||||
|
||||
root := filepath.Dir(filepath.Dir(filepath.Dir(filepath.Dir(filepath.Dir(abs)))))
|
||||
specpath := filepath.Join(root, "api", "openapi-spec", "swagger.json")
|
||||
_, err = os.Stat(specpath)
|
||||
if err != nil {
|
||||
d.err = err
|
||||
return
|
||||
}
|
||||
spec, err := ioutil.ReadFile(specpath)
|
||||
if err != nil {
|
||||
d.err = err
|
||||
return
|
||||
}
|
||||
var info yaml.MapSlice
|
||||
err = yaml.Unmarshal(spec, &info)
|
||||
if err != nil {
|
||||
d.err = err
|
||||
return
|
||||
}
|
||||
d.data, d.err = openapi_v2.NewDocument(info, compiler.NewContext("$root", nil))
|
||||
})
|
||||
return d.data, d.err
|
||||
}
|
||||
|
||||
type fakeOpenAPIClient struct {
|
||||
calls int
|
||||
err error
|
||||
}
|
||||
|
||||
func (f *fakeOpenAPIClient) OpenAPISchema() (*openapi_v2.Document, error) {
|
||||
f.calls = f.calls + 1
|
||||
|
||||
if f.err != nil {
|
||||
return nil, f.err
|
||||
}
|
||||
|
||||
return data.OpenAPISchema()
|
||||
}
|
||||
|
||||
var _ = Describe("Getting the Resources", func() {
|
||||
var client *tst.FakeClient
|
||||
var expectedData openapi.Resources
|
||||
|
|
Loading…
Reference in New Issue