Skip to content

Commit

Permalink
Document issue with failing test
Browse files Browse the repository at this point in the history
  • Loading branch information
AndrewSisley committed Sep 27, 2023
1 parent 2c862ac commit b2ec0f3
Showing 1 changed file with 194 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,194 @@
// Copyright 2023 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 (
"fmt"
"testing"

testUtils "github.com/sourcenetwork/defradb/tests/integration"
)

func TestMutationUpdateOneToOne_SelfReferencingFromPrimary(t *testing.T) {
user1ID := "bae-decf6467-4c7c-50d7-b09d-0a7097ef6bad"

test := testUtils.TestCase{
Description: "One to one update mutation, self referencing from primary",
Actions: []any{
testUtils.SchemaUpdate{
Schema: `
type User {
name: String
boss: User @primary
underling: User
}
`,
},
testUtils.CreateDoc{
Doc: `{
"name": "John"
}`,
},
testUtils.CreateDoc{
Doc: `{
"name": "Fred"
}`,
},
testUtils.UpdateDoc{
DocID: 1,
Doc: fmt.Sprintf(
`{
"boss_id": "%s"
}`,
user1ID,
),
},
testUtils.Request{
Request: `
query {
User {
name
boss {
name
}
}
}`,
Results: []map[string]any{
{
"name": "Fred",
"boss": map[string]any{
"name": "John",
},
},
{
"name": "John",
"boss": nil,
},
},
},
testUtils.Request{
Request: `
query {
User {
name
underling {
name
}
}
}`,
Results: []map[string]any{
{
"name": "Fred",
"underling": nil,
},
{
"name": "John",
"underling": map[string]any{
"name": "Fred",
},
},
},
},
},
}

testUtils.ExecuteTestCase(t, test)
}

/*
This test will enter an infinite loop
func TestMutationUpdateOneToOne_SelfReferencingFromSecondary(t *testing.T) {
user1ID := "bae-decf6467-4c7c-50d7-b09d-0a7097ef6bad"
test := testUtils.TestCase{
Description: "One to one update mutation, self referencing from secondary",
Actions: []any{
testUtils.SchemaUpdate{
Schema: `
type User {
name: String
boss: User
underling: User @primary
}
`,
},
testUtils.CreateDoc{
Doc: `{
"name": "John"
}`,
},
testUtils.CreateDoc{
Doc: `{
"name": "Fred"
}`,
},
testUtils.UpdateDoc{
DocID: 1,
Doc: fmt.Sprintf(
`{
"boss_id": "%s"
}`,
user1ID,
),
},
testUtils.Request{
Request: `
query {
User {
name
boss {
name
}
}
}`,
Results: []map[string]any{
{
"name": "Fred",
"boss": map[string]any{
"name": "John",
},
},
{
"name": "John",
"boss": nil,
},
},
},
testUtils.Request{
Request: `
query {
User {
name
underling {
name
}
}
}`,
Results: []map[string]any{
{
"name": "Fred",
"underling": nil,
},
{
"name": "John",
"underling": map[string]any{
"name": "Fred",
},
},
},
},
},
}
testUtils.ExecuteTestCase(t, test)
}
*/

0 comments on commit b2ec0f3

Please sign in to comment.