-
Notifications
You must be signed in to change notification settings - Fork 66
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(changes): "left" side of report should be the previous path
The upper layers & the UI powered by the `Report` method expect that if the `leftRef` is empty, we should just use the `PreviousPath` of the `rightRef` as the `left` dataset to compare to. This bug only occurs if the `left` side is empty, and currently all our `ChangeReport` consumers have filled in both versions to compare. There is now a test that ensures the behavior is correct.
- Loading branch information
Showing
2 changed files
with
45 additions
and
4 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package lib | ||
|
||
import ( | ||
"context" | ||
"testing" | ||
|
||
testcfg "github.com/qri-io/qri/config/test" | ||
"github.com/qri-io/qri/event" | ||
"github.com/qri-io/qri/p2p" | ||
testrepo "github.com/qri-io/qri/repo/test" | ||
) | ||
|
||
func TestChanges(t *testing.T) { | ||
ctx, done := context.WithCancel(context.Background()) | ||
defer done() | ||
|
||
mr, err := testrepo.NewTestRepo() | ||
if err != nil { | ||
t.Fatalf("error allocating test repo: %s", err.Error()) | ||
} | ||
node, err := p2p.NewQriNode(mr, testcfg.DefaultP2PForTesting(), event.NilBus, nil) | ||
if err != nil { | ||
t.Fatal(err.Error()) | ||
} | ||
inst := NewInstanceFromConfigAndNode(ctx, testcfg.DefaultConfigForTesting(), node) | ||
|
||
InitWorldBankDataset(ctx, t, inst) | ||
commitref := Commit2WorldBank(ctx, t, inst) | ||
|
||
// test ChangeReport with one param | ||
p := &ChangeReportParams{ | ||
RightRefstr: commitref.Alias(), | ||
} | ||
if _, err := inst.Dataset().ChangeReport(ctx, p); err != nil { | ||
t.Fatalf("change report error: %s", err) | ||
} | ||
} |