Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Weos 1240 #46

Merged
merged 28 commits into from
Jan 18, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
39dbb94
WEOS-1256
atoniaw Jan 9, 2022
bb2afef
Merge remote-tracking branch 'origin/dev' into WEOS-1256
atoniaw Jan 9, 2022
2290033
Merge branch 'feature/WEOS-1135' into WEOS-1256
atoniaw Jan 9, 2022
1eaff9a
WEOS-1256 - Create projection functions to get entity by keys and by …
atoniaw Jan 9, 2022
da58ed9
WEOS-1256
atoniaw Jan 9, 2022
161f3df
WEOS-1256
atoniaw Jan 9, 2022
ac2e1ab
WEOS-1256
atoniaw Jan 10, 2022
ffddb07
Merge branch 'WEOS-1245' into WEOS-1256
atoniaw Jan 13, 2022
0f91fa6
WEOS-1256
atoniaw Jan 13, 2022
a13209a
WEOS-1245
atoniaw Jan 13, 2022
b29ebae
feature:WEOS-1132
RandyDeo Jan 13, 2022
e1b20d5
WEOS-1256
atoniaw Jan 13, 2022
baf3f71
feature:WEOS-1132
RandyDeo Jan 13, 2022
b3d8a0f
feature:WEOS-1132
RandyDeo Jan 14, 2022
1d313e4
feature:WEOS-1132
RandyDeo Jan 14, 2022
349245c
Merge pull request #40 from wepala/WEOS-1245
RandyDeo Jan 14, 2022
3d1901b
Merge pull request #41 from wepala/WEOS-1256
shaniah868 Jan 14, 2022
ee88035
feature:WEOS-1132
RandyDeo Jan 14, 2022
11548cf
Merge remote-tracking branch 'origin/feature/WEOS-1135' into WEOS-1240
RandyDeo Jan 14, 2022
3e56793
Merge branch 'feature/WEOS-1135' into WEOS-1240
RandyDeo Jan 14, 2022
39f725b
feature:WEOS-1132
RandyDeo Jan 14, 2022
6a5f7b2
feature:WEOS-1132
RandyDeo Jan 17, 2022
81a9cc4
Merge branch 'feature/WEOS-1132' into WEOS-1240
RandyDeo Jan 17, 2022
453fb2d
feature:WEOS-1132
RandyDeo Jan 17, 2022
bb6106c
feature:WEOS-1123
RandyDeo Jan 17, 2022
5221533
feature:WEOS-1132
RandyDeo Jan 17, 2022
71a506e
feature:WEOS-1132
RandyDeo Jan 17, 2022
c1433c2
feature:WEOS-1132
RandyDeo Jan 18, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 47 additions & 0 deletions controllers/rest/api_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -269,3 +269,50 @@ func TestRESTAPI_Initialize_ViewAddedToGet(t *testing.T) {
}
os.Remove("test.db")
}

func TestRESTAPI_Initialize_GetEntityBySequenceNuber(t *testing.T) {
os.Remove("test.db")
time.Sleep(1 * time.Second)
e := echo.New()
tapi := api.RESTAPI{}
_, err := api.Initialize(e, &tapi, "./fixtures/blog-create-batch.yaml")
if err != nil {
t.Fatalf("unexpected error '%s'", err)
}
mockBlog := &[3]Blog{
{ID: "1asdas3", Title: "Blog 1", Url: "www.testBlog1.com"},
{ID: "2gf233", Title: "Blog 2", Url: "www.testBlog2.com"},
{ID: "3dgff3", Title: "Blog 3", Url: "www.testBlog3.com"},
}
reqBytes, err := json.Marshal(mockBlog)
if err != nil {
t.Fatalf("error setting up request %s", err)
}
body := bytes.NewReader(reqBytes)
resp := httptest.NewRecorder()
req := httptest.NewRequest(http.MethodPost, "/blogs", body)
e.ServeHTTP(resp, req)
//confirm that the response is 201
if resp.Result().StatusCode != http.StatusCreated {
t.Errorf("expected the response code to be %d, got %d", http.StatusCreated, resp.Result().StatusCode)
}

blogEntity, err := api.GetContentBySequenceNumber(tapi.Application.EventRepository(), "3dgff3", 4)
if err != nil {
t.Fatal(err)
}

mapEntity, ok := blogEntity.Property.(map[string]interface{})

if !ok {
t.Fatal("expected the properties of the blog entity to be mapable")
}
if mapEntity["title"] != "Blog 3" {
t.Errorf("expected the title to be %s got %s", "Blog 3", mapEntity["title"])
}

if blogEntity.SequenceNo != int64(1) {
t.Errorf("expected the sequence number to be %d got %d", blogEntity.SequenceNo, 1)
}
os.Remove("test.db")
}
Loading