mirror of
https://github.com/kubeshark/kubeshark.git
synced 2026-05-20 16:13:46 +00:00
* Update main.go, main.go, and 3 more files... * WIP * Update main.go, oas_controller.go, and 3 more files... * Update main.go, oas_generator.go, and servicemap.go * Update loader.go and resolver.go * Update oas_generator.go * Update oas_generator.go, specgen_test.go, and 3 more files... * Update service_map_controller_test.go * Update oas_controller_test.go
50 lines
1.6 KiB
Go
50 lines
1.6 KiB
Go
package controllers
|
|
|
|
import (
|
|
"net/http/httptest"
|
|
"testing"
|
|
|
|
"github.com/up9inc/mizu/agent/pkg/dependency"
|
|
"github.com/up9inc/mizu/agent/pkg/oas"
|
|
|
|
"github.com/gin-gonic/gin"
|
|
)
|
|
|
|
func TestGetOASServers(t *testing.T) {
|
|
dependency.RegisterGenerator(dependency.OasGeneratorDependency, func() interface{} { return oas.GetDefaultOasGeneratorInstance() })
|
|
|
|
recorder := httptest.NewRecorder()
|
|
c, _ := gin.CreateTestContext(recorder)
|
|
oas.GetDefaultOasGeneratorInstance().Start()
|
|
oas.GetDefaultOasGeneratorInstance().GetServiceSpecs().Store("some", oas.NewGen("some"))
|
|
|
|
GetOASServers(c)
|
|
t.Logf("Written body: %s", recorder.Body.String())
|
|
}
|
|
|
|
func TestGetOASAllSpecs(t *testing.T) {
|
|
dependency.RegisterGenerator(dependency.OasGeneratorDependency, func() interface{} { return oas.GetDefaultOasGeneratorInstance() })
|
|
|
|
recorder := httptest.NewRecorder()
|
|
c, _ := gin.CreateTestContext(recorder)
|
|
oas.GetDefaultOasGeneratorInstance().Start()
|
|
oas.GetDefaultOasGeneratorInstance().GetServiceSpecs().Store("some", oas.NewGen("some"))
|
|
|
|
GetOASAllSpecs(c)
|
|
t.Logf("Written body: %s", recorder.Body.String())
|
|
}
|
|
|
|
func TestGetOASSpec(t *testing.T) {
|
|
dependency.RegisterGenerator(dependency.OasGeneratorDependency, func() interface{} { return oas.GetDefaultOasGeneratorInstance() })
|
|
|
|
recorder := httptest.NewRecorder()
|
|
c, _ := gin.CreateTestContext(recorder)
|
|
oas.GetDefaultOasGeneratorInstance().Start()
|
|
oas.GetDefaultOasGeneratorInstance().GetServiceSpecs().Store("some", oas.NewGen("some"))
|
|
|
|
c.Params = []gin.Param{{Key: "id", Value: "some"}}
|
|
|
|
GetOASSpec(c)
|
|
t.Logf("Written body: %s", recorder.Body.String())
|
|
}
|