Skip to content

Commit

Permalink
LEAF-4487 - add in the tests for the differing variations.
Browse files Browse the repository at this point in the history
  • Loading branch information
shane committed Dec 5, 2024
1 parent 72a6e5f commit 58ffd34
Showing 1 changed file with 61 additions and 2 deletions.
63 changes: 61 additions & 2 deletions API-tests/formQuery_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -292,12 +292,31 @@ func TestLargeFormQuery_SmallQuery(t *testing.T) {
t.Errorf("Record 958 should be readable")
}

if res.Header.Get("Leaf_large_queries") != "pass_onto_large_query_server" {
if res.Header.Get("Leaf_large_queries") != "process_ran_on_api_server" {
t.Errorf("bad headers: %v", res.Header)
}
}

func TestLargeFormQuery_LargeQuery(t *testing.T) {
func TestLargeFormQuery_SmallQuery_Indi_lt10_Limit1001(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":[],"sort":{},"getData":["9","8","10","4","5","7","3","6"],"limit":1001}&x-filterData=recordID,title`

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_api_server" {
t.Errorf("bad headers: %v", res.Header)
}
}

func TestLargeFormQuery_LargeQuery_NoLimit(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)
Expand All @@ -316,3 +335,43 @@ func TestLargeFormQuery_LargeQuery(t *testing.T) {
}

}

func TestLargeFormQuery_LargeQuery_LimitGT110000(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"],"limit":10001}&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)
}

}

func TestLargeFormQuery_LargeQuery_Indi_10_Limit1001(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":[],"sort":{},"getData":["9","8","10","4","5","7","3","6","2","-7","-5","-6","-2","-1","-4","14","15","12","1"],"limit":1001}&x-filterData=recordID,title`

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)
}

}

0 comments on commit 58ffd34

Please sign in to comment.