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

LEAF-4487 - Large Queries #11

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Changes from 4 commits
Commits
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
50 changes: 44 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,42 @@ 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 res.Header.Get("Leaf_large_queries") != "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 res.Header.Get("Leaf_large_queries") != "process_ran_on_large_query_server" {
t.Errorf("bad headers: %v", res.Header)
}

}