-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: Add bug bash tests for gql fragments (#3136)
## Relevant issue(s) Resolves #3135 ## Description Adds bug bash tests for gql fragments with inner objects. No bugs found.
- Loading branch information
1 parent
6cc39a7
commit c549570
Showing
1 changed file
with
142 additions
and
0 deletions.
There are no files selected for viewing
142 changes: 142 additions & 0 deletions
142
tests/integration/query/one_to_one/with_fragments_test.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,142 @@ | ||
// Copyright 2024 Democratized Data Foundation | ||
// | ||
// Use of this software is governed by the Business Source License | ||
// included in the file licenses/BSL.txt. | ||
// | ||
// As of the Change Date specified in that file, in accordance with | ||
// the Business Source License, use of this software will be governed | ||
// by the Apache License, Version 2.0, included in the file | ||
// licenses/APL.txt. | ||
|
||
package one_to_one | ||
|
||
import ( | ||
"testing" | ||
|
||
testUtils "github.com/sourcenetwork/defradb/tests/integration" | ||
) | ||
|
||
func TestQueryOneToOne_WithFragment(t *testing.T) { | ||
test := testUtils.TestCase{ | ||
Actions: []any{ | ||
testUtils.SchemaUpdate{ | ||
Schema: ` | ||
type Book { | ||
name: String | ||
author: Author | ||
} | ||
type Author { | ||
name: String | ||
age: Int | ||
} | ||
`, | ||
}, | ||
testUtils.CreateDoc{ | ||
CollectionID: 1, | ||
Doc: `{ | ||
"name": "John Grisham", | ||
"age": 65 | ||
}`, | ||
}, | ||
testUtils.CreateDoc{ | ||
CollectionID: 0, | ||
DocMap: map[string]any{ | ||
"name": "Painted House", | ||
"author": testUtils.NewDocIndex(1, 0), | ||
}, | ||
}, | ||
testUtils.Request{ | ||
Request: `query { | ||
Book { | ||
name | ||
...BookAuthorInfo | ||
} | ||
} | ||
fragment BookAuthorInfo on Book { | ||
author { | ||
name | ||
age | ||
} | ||
}`, | ||
Results: map[string]any{ | ||
"Book": []map[string]any{ | ||
{ | ||
"name": "Painted House", | ||
"author": map[string]any{ | ||
"name": "John Grisham", | ||
"age": int64(65), | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
} | ||
|
||
testUtils.ExecuteTestCase(t, test) | ||
} | ||
|
||
func TestQueryOneToOne_WithFragmentWithObjectWithFragment(t *testing.T) { | ||
test := testUtils.TestCase{ | ||
Actions: []any{ | ||
testUtils.SchemaUpdate{ | ||
Schema: ` | ||
type Book { | ||
name: String | ||
author: Author | ||
} | ||
type Author { | ||
name: String | ||
age: Int | ||
} | ||
`, | ||
}, | ||
testUtils.CreateDoc{ | ||
CollectionID: 1, | ||
Doc: `{ | ||
"name": "John Grisham", | ||
"age": 65 | ||
}`, | ||
}, | ||
testUtils.CreateDoc{ | ||
CollectionID: 0, | ||
DocMap: map[string]any{ | ||
"name": "Painted House", | ||
"author": testUtils.NewDocIndex(1, 0), | ||
}, | ||
}, | ||
testUtils.Request{ | ||
Request: `query { | ||
Book { | ||
name | ||
...BookAuthorInfo | ||
} | ||
} | ||
fragment BookAuthorInfo on Book { | ||
author { | ||
...BookInfo | ||
} | ||
} | ||
fragment BookInfo on Author { | ||
name | ||
age | ||
}`, | ||
Results: map[string]any{ | ||
"Book": []map[string]any{ | ||
{ | ||
"name": "Painted House", | ||
"author": map[string]any{ | ||
"name": "John Grisham", | ||
"age": int64(65), | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
} | ||
|
||
testUtils.ExecuteTestCase(t, test) | ||
} |