-
Notifications
You must be signed in to change notification settings - Fork 51
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Add support for branchable collection time-traveling (#3260)
## Relevant issue(s) Resolves #3257 ## Description Add support for branchable collection time-traveling. Also fixes the docID param which was misbehaving (see commit `Create document with actual docID not user provided value`).
- Loading branch information
1 parent
c45b07e
commit fa0d92b
Showing
6 changed files
with
287 additions
and
69 deletions.
There are no files selected for viewing
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
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
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
161 changes: 161 additions & 0 deletions
161
tests/integration/query/simple/with_cid_branchable_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,161 @@ | ||
// 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 simple | ||
|
||
import ( | ||
"testing" | ||
|
||
testUtils "github.com/sourcenetwork/defradb/tests/integration" | ||
) | ||
|
||
func TestQuerySimpleWithCidOfBranchableCollection_FirstCid(t *testing.T) { | ||
test := testUtils.TestCase{ | ||
Actions: []any{ | ||
testUtils.SchemaUpdate{ | ||
Schema: ` | ||
type Users @branchable { | ||
name: String | ||
} | ||
`, | ||
}, | ||
testUtils.CreateDoc{ | ||
Doc: `{ | ||
"name": "Fred" | ||
}`, | ||
}, | ||
testUtils.UpdateDoc{ | ||
Doc: `{ | ||
"name": "Freddddd" | ||
}`, | ||
}, | ||
testUtils.CreateDoc{ | ||
Doc: `{ | ||
"name": "John" | ||
}`, | ||
}, | ||
testUtils.Request{ | ||
Request: `query { | ||
Users ( | ||
cid: "bafyreiewwsnu2ld5qlntamdm77ayb7xtmxz3p5difvaaakaome7zbtpo4u" | ||
) { | ||
name | ||
} | ||
}`, | ||
Results: map[string]any{ | ||
"Users": []map[string]any{ | ||
{ | ||
"name": "Fred", | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
} | ||
|
||
testUtils.ExecuteTestCase(t, test) | ||
} | ||
|
||
func TestQuerySimpleWithCidOfBranchableCollection_MiddleCid(t *testing.T) { | ||
test := testUtils.TestCase{ | ||
Actions: []any{ | ||
testUtils.SchemaUpdate{ | ||
Schema: ` | ||
type Users @branchable { | ||
name: String | ||
} | ||
`, | ||
}, | ||
testUtils.CreateDoc{ | ||
Doc: `{ | ||
"name": "Fred" | ||
}`, | ||
}, | ||
testUtils.UpdateDoc{ | ||
Doc: `{ | ||
"name": "Freddddd" | ||
}`, | ||
}, | ||
testUtils.CreateDoc{ | ||
Doc: `{ | ||
"name": "John" | ||
}`, | ||
}, | ||
testUtils.Request{ | ||
Request: `query { | ||
Users ( | ||
cid: "bafyreifpamlyhcbriztgbhds5ctgi5rm6w5wcar2py7246lo6j5v7iusxm" | ||
) { | ||
name | ||
} | ||
}`, | ||
Results: map[string]any{ | ||
"Users": []map[string]any{ | ||
{ | ||
"name": "Freddddd", | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
} | ||
|
||
testUtils.ExecuteTestCase(t, test) | ||
} | ||
|
||
func TestQuerySimpleWithCidOfBranchableCollection_LastCid(t *testing.T) { | ||
test := testUtils.TestCase{ | ||
Actions: []any{ | ||
testUtils.SchemaUpdate{ | ||
Schema: ` | ||
type Users @branchable { | ||
name: String | ||
} | ||
`, | ||
}, | ||
testUtils.CreateDoc{ | ||
Doc: `{ | ||
"name": "Fred" | ||
}`, | ||
}, | ||
testUtils.UpdateDoc{ | ||
Doc: `{ | ||
"name": "Freddddd" | ||
}`, | ||
}, | ||
testUtils.CreateDoc{ | ||
Doc: `{ | ||
"name": "John" | ||
}`, | ||
}, | ||
testUtils.Request{ | ||
Request: `query { | ||
Users ( | ||
cid: "bafyreigmt6ytph32jjxts2bij7fkne5ntionldsnklp35vcamvvl2x3a5i" | ||
) { | ||
name | ||
} | ||
}`, | ||
Results: map[string]any{ | ||
"Users": []map[string]any{ | ||
{ | ||
"name": "Freddddd", | ||
}, | ||
{ | ||
"name": "John", | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
} | ||
|
||
testUtils.ExecuteTestCase(t, test) | ||
} |
Oops, something went wrong.