Skip to content

Commit

Permalink
Merge branch 'dev' into feature/WEOS-1342
Browse files Browse the repository at this point in the history
# Conflicts:
#	controllers/rest/api_test.go
  • Loading branch information
RandyDeo committed Mar 16, 2022
2 parents 9176aa6 + 98e1de3 commit 0bd06ce
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 1 deletion.
2 changes: 1 addition & 1 deletion controllers/rest/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -349,8 +349,8 @@ func (p *RESTAPI) Initialize(ctxt context.Context) error {
p.RegisterGlobalInitializer(Security)
//register standard operation initializers
p.RegisterOperationInitializer(ContextInitializer)
p.RegisterOperationInitializer(DefaultResponseInitializer)
p.RegisterOperationInitializer(ContentTypeResponseInitializer)
p.RegisterOperationInitializer(DefaultResponseInitializer)
p.RegisterOperationInitializer(EntityFactoryInitializer)
p.RegisterOperationInitializer(UserDefinedInitializer)
p.RegisterOperationInitializer(StandardInitializer)
Expand Down
26 changes: 26 additions & 0 deletions controllers/rest/api_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -656,6 +656,32 @@ paths:
time.Sleep(1 * time.Second)
}

func TestRESTAPI_Initialize_ExampleResponse(t *testing.T) {
os.Remove("test.db")
var header http.Header
tapi, err := api.New("./fixtures/blog.yaml")
if err != nil {
t.Fatalf("un expected error loading spec '%s'", err)
}
err = tapi.Initialize(context.TODO())
if err != nil {
t.Fatalf("un expected error loading spec '%s'", err)
}
e := tapi.EchoInstance()
resp := httptest.NewRecorder()
req := httptest.NewRequest(http.MethodGet, "/", nil)
header = http.Header{}
header.Set(echo.HeaderContentType, echo.MIMEApplicationJSON)
req.Header = header
req.Close = true
e.ServeHTTP(resp, req)

if resp.Result().StatusCode != http.StatusCreated {
t.Fatalf("expected to get status %d got %d", http.StatusCreated, resp.Result().StatusCode)
}
os.Remove("test.db")
}

func TestRESTAPI_Integration_AutomaticallyUpdateDateTime(t *testing.T) {
tapi, err := api.New("./fixtures/blog.yaml")
if err != nil {
Expand Down

0 comments on commit 0bd06ce

Please sign in to comment.