Skip to content

Commit

Permalink
LEAF-4487 - large query move test into form query and make test fail …
Browse files Browse the repository at this point in the history
…when large query server/code is not in use
  • Loading branch information
shane committed Dec 2, 2024
1 parent 5f9eab1 commit 094343d
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 52 deletions.
49 changes: 43 additions & 6 deletions API-tests/formQuery_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -208,15 +208,14 @@ func TestFormQuery_FindTwoSteps(t *testing.T) {
}
}


/* post a new employee to an orgchart format question and then confirm expected values on orgchart property */
func TestFormQuery_Employee_Format__Orgchart_Has_Expected_Values(t *testing.T) {
mock_orgchart_employee := FormQuery_Orgchart_Employee{
FirstName: "Ramon",
LastName: "Watsica",
FirstName: "Ramon",
LastName: "Watsica",
MiddleName: "Yundt",
Email: "[email protected]",
UserName: "vtrycxbethany",
Email: "[email protected]",
UserName: "vtrycxbethany",
}

postData := url.Values{}
Expand All @@ -243,7 +242,7 @@ func TestFormQuery_Employee_Format__Orgchart_Has_Expected_Values(t *testing.T) {
recData := formRes[11].S1

dataInterface := recData["id8_orgchart"]
orgchart := dataInterface.(map[string]interface {})
orgchart := dataInterface.(map[string]interface{})
b, _ := json.Marshal(orgchart)

var org_emp FormQuery_Orgchart_Employee
Expand Down Expand Up @@ -278,3 +277,41 @@ func TestFormQuery_Employee_Format__Orgchart_Has_Expected_Values(t *testing.T) {
t.Errorf("userName got = %v, want = %v", got, want)
}
}

func TestLargeFormQuery_SmallQuery(t *testing.T) {
url := RootURL + `api/form/query/?q={"terms":[{"id":"stepID","operator":"!=","match":"resolved","gate":"AND"},{"id":"deleted","operator":"=","match":0,"gate":"AND"}],"joins":["status","initiatorName"],"sort":{},"limit":10000,"getData":["9","8","10","4","5","7","3","6","2"]}&x-filterData=recordID,title,stepTitle,lastStatus,lastName,firstName`

url = strings.Replace(url, " ", "%20", -1)
res, _ := client.Get(url)
b, _ := io.ReadAll(res.Body)

var formQueryResponse FormQueryResponse
_ = json.Unmarshal(b, &formQueryResponse)

if _, exists := formQueryResponse[958]; !exists {
t.Errorf("Record 958 should be readable")
}

if v, ok := res.Header["Leaf_large_queries"]; ok && v[0] != "pass_onto_large_query_server" {
t.Errorf("bad headers: %v", res.Header)
}
}

func TestLargeFormQuery_LargeQuery(t *testing.T) {
url := RootURL + `api/form/query/?q={"terms":[{"id":"stepID","operator":"!=","match":"resolved","gate":"AND"},{"id":"deleted","operator":"=","match":0,"gate":"AND"}],"joins":["status","initiatorName"],"sort":{},"getData":["9","8","10","4","5","7","3","6","2"]}&x-filterData=recordID,title,stepTitle,lastStatus,lastName,firstName`

url = strings.Replace(url, " ", "%20", -1)
res, _ := client.Get(url)
b, _ := io.ReadAll(res.Body)

var formQueryResponse FormQueryResponse
_ = json.Unmarshal(b, &formQueryResponse)

if _, exists := formQueryResponse[958]; !exists {
t.Errorf("Record 958 should be readable")
}

if v, ok := res.Header["Leaf_large_queries"]; ok && v[0] != "process_ran_on_large_query_server" {
t.Errorf("bad headers: %v", res.Header)
}
}
46 changes: 0 additions & 46 deletions API-tests/largeFormQuery_test.go

This file was deleted.

0 comments on commit 094343d

Please sign in to comment.