Skip to content

Commit

Permalink
test: Add bug bash tests for gql fragments (#3136)
Browse files Browse the repository at this point in the history
## Relevant issue(s)

Resolves #3135 

## Description

Adds bug bash tests for gql fragments with inner objects. No bugs found.
  • Loading branch information
AndrewSisley authored Oct 16, 2024
1 parent 6cc39a7 commit c549570
Showing 1 changed file with 142 additions and 0 deletions.
142 changes: 142 additions & 0 deletions tests/integration/query/one_to_one/with_fragments_test.go
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)
}

0 comments on commit c549570

Please sign in to comment.