-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(server): request approval should publish the exact version (#1291)
* fix(server): request approval should publish the exact version * fix test * fix test
- Loading branch information
1 parent
af0bd0d
commit cae24f8
Showing
8 changed files
with
218 additions
and
32 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -991,8 +991,22 @@ func TestWorkFlow(t *testing.T) { | |
s := schema.New().NewID().Workspace(accountdomain.NewWorkspaceID()).Project(prj.ID()).MustBuild() | ||
m := model.New().NewID().Project(prj.ID()).Schema(s.ID()).RandomKey().MustBuild() | ||
i := item.New().NewID().Schema(s.ID()).Model(m.ID()).Project(prj.ID()).Thread(id.NewThreadID()).MustBuild() | ||
ri, _ := request.NewItem(i.ID(), lo.ToPtr(version.New().String())) | ||
u := user.New().Name("aaa").NewID().Email("[email protected]").Workspace(wid).MustBuild() | ||
|
||
ctx := context.Background() | ||
db := memory.New() | ||
err := db.Project.Save(ctx, prj) | ||
assert.NoError(t, err) | ||
err = db.Schema.Save(ctx, s) | ||
assert.NoError(t, err) | ||
err = db.Model.Save(ctx, m) | ||
assert.NoError(t, err) | ||
err = db.Item.Save(ctx, i) | ||
assert.NoError(t, err) | ||
|
||
vi, err := db.Item.FindByID(ctx, i.ID(), nil) | ||
assert.NoError(t, err) | ||
ri, _ := request.NewItem(i.ID(), lo.ToPtr(vi.Version().String())) | ||
req1 := request.New(). | ||
NewID(). | ||
Workspace(wid). | ||
|
@@ -1009,17 +1023,6 @@ func TestWorkFlow(t *testing.T) { | |
OwningWorkspaces: id.WorkspaceIDList{wid}, | ||
}, | ||
} | ||
ctx := context.Background() | ||
|
||
db := memory.New() | ||
err := db.Project.Save(ctx, prj) | ||
assert.NoError(t, err) | ||
err = db.Schema.Save(ctx, s) | ||
assert.NoError(t, err) | ||
err = db.Model.Save(ctx, m) | ||
assert.NoError(t, err) | ||
err = db.Item.Save(ctx, i) | ||
assert.NoError(t, err) | ||
|
||
itemUC := NewItem(db, nil) | ||
|
||
|
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 |
---|---|---|
|
@@ -353,21 +353,38 @@ func TestRequest_Approve(t *testing.T) { | |
defer util.MockNow(now)() | ||
|
||
// TODO: add error cases | ||
wid := accountdomain.NewWorkspaceID() | ||
prj := project.New().NewID().MustBuild() | ||
s := schema.New().NewID().Workspace(accountdomain.NewWorkspaceID()).Project(prj.ID()).MustBuild() | ||
m := model.New().NewID().Schema(s.ID()).RandomKey().MustBuild() | ||
i := item.New().NewID().Schema(s.ID()).Model(m.ID()).Project(prj.ID()).Thread(id.NewThreadID()).MustBuild() | ||
item, _ := request.NewItem(i.ID(), lo.ToPtr(version.New().String())) | ||
wid := accountdomain.NewWorkspaceID() | ||
u := user.New().Name("aaa").NewID().Email("[email protected]").Workspace(wid).MustBuild() | ||
|
||
ctx := context.Background() | ||
db := memory.New() | ||
// if tc.mockRequestErr { | ||
// memory.SetRequestError(db.Request, tc.wantErr) | ||
// } | ||
err := db.Project.Save(ctx, prj) | ||
assert.NoError(t, err) | ||
err = db.Schema.Save(ctx, s) | ||
assert.NoError(t, err) | ||
err = db.Model.Save(ctx, m) | ||
assert.NoError(t, err) | ||
err = db.Item.Save(ctx, i) | ||
assert.NoError(t, err) | ||
|
||
vi, err := db.Item.FindByID(ctx, i.ID(), nil) | ||
assert.NoError(t, err) | ||
ri, _ := request.NewItem(i.ID(), lo.ToPtr(vi.Version().String())) | ||
req1 := request.New(). | ||
NewID(). | ||
Workspace(wid). | ||
Project(prj.ID()). | ||
Reviewers(accountdomain.UserIDList{u.ID()}). | ||
CreatedBy(accountdomain.NewUserID()). | ||
Thread(id.NewThreadID()). | ||
Items(request.ItemList{item}). | ||
Items(request.ItemList{ri}). | ||
Title("foo"). | ||
MustBuild() | ||
op := &usecase.Operator{ | ||
|
@@ -376,22 +393,9 @@ func TestRequest_Approve(t *testing.T) { | |
OwningWorkspaces: accountdomain.WorkspaceIDList{wid}, | ||
}, | ||
} | ||
ctx := context.Background() | ||
|
||
db := memory.New() | ||
// if tc.mockRequestErr { | ||
// memory.SetRequestError(db.Request, tc.wantErr) | ||
// } | ||
err := db.Project.Save(ctx, prj) | ||
assert.NoError(t, err) | ||
err = db.Request.Save(ctx, req1) | ||
assert.NoError(t, err) | ||
err = db.Schema.Save(ctx, s) | ||
assert.NoError(t, err) | ||
err = db.Model.Save(ctx, m) | ||
assert.NoError(t, err) | ||
err = db.Item.Save(ctx, i) | ||
assert.NoError(t, err) | ||
|
||
requestUC := NewRequest(db, nil) | ||
_, err = requestUC.Approve(ctx, req1.ID(), op) | ||
|