-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
set dying only if juju api don't fail
- Loading branch information
1 parent
10111ef
commit f29457e
Showing
2 changed files
with
39 additions
and
26 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 |
---|---|---|
|
@@ -3141,6 +3141,7 @@ var destroyModelTests = []struct { | |
timeout *time.Duration | ||
expectError string | ||
expectErrorCode errors.Code | ||
expectedLife string | ||
}{{ | ||
name: "NotFound", | ||
env: destroyModelTestEnv, | ||
|
@@ -3182,30 +3183,34 @@ var destroyModelTests = []struct { | |
force: newBool(false), | ||
maxWait: newDuration(time.Second), | ||
timeout: newDuration(time.Second), | ||
expectedLife: "dying", | ||
}, { | ||
name: "SuperuserSuccess", | ||
env: destroyModelTestEnv, | ||
destroyModel: func(_ context.Context, _ names.ModelTag, _, _ *bool, _, _ *time.Duration) error { | ||
return nil | ||
}, | ||
username: "[email protected]", | ||
uuid: "00000002-0000-0000-0000-000000000001", | ||
username: "[email protected]", | ||
uuid: "00000002-0000-0000-0000-000000000001", | ||
expectedLife: "dying", | ||
}, { | ||
name: "DialError", | ||
env: destroyModelTestEnv, | ||
dialError: errors.E("dial error"), | ||
username: "[email protected]", | ||
uuid: "00000002-0000-0000-0000-000000000001", | ||
expectError: `dial error`, | ||
name: "DialError", | ||
env: destroyModelTestEnv, | ||
dialError: errors.E("dial error"), | ||
username: "[email protected]", | ||
uuid: "00000002-0000-0000-0000-000000000001", | ||
expectError: `dial error`, | ||
expectedLife: "alive", | ||
}, { | ||
name: "APIError", | ||
env: destroyModelTestEnv, | ||
destroyModel: func(_ context.Context, _ names.ModelTag, _, _ *bool, _, _ *time.Duration) error { | ||
return errors.E("api error") | ||
}, | ||
username: "[email protected]", | ||
uuid: "00000002-0000-0000-0000-000000000001", | ||
expectError: `api error`, | ||
username: "[email protected]", | ||
uuid: "00000002-0000-0000-0000-000000000001", | ||
expectError: `api error`, | ||
expectedLife: "alive", | ||
}} | ||
|
||
func TestDestroyModel(t *testing.T) { | ||
|
@@ -3249,18 +3254,20 @@ func TestDestroyModel(t *testing.T) { | |
if test.expectErrorCode != "" { | ||
c.Check(errors.ErrorCode(err), qt.Equals, test.expectErrorCode) | ||
} | ||
return | ||
} else { | ||
c.Assert(err, qt.IsNil) | ||
} | ||
c.Assert(err, qt.IsNil) | ||
m := dbmodel.Model{ | ||
UUID: sql.NullString{ | ||
String: test.uuid, | ||
Valid: true, | ||
}, | ||
if test.expectedLife != "" { | ||
m := dbmodel.Model{ | ||
UUID: sql.NullString{ | ||
String: test.uuid, | ||
Valid: true, | ||
}, | ||
} | ||
err = j.Database.GetModel(ctx, &m) | ||
c.Assert(err, qt.IsNil) | ||
c.Assert(m.Life, qt.Equals, test.expectedLife) | ||
} | ||
err = j.Database.GetModel(ctx, &m) | ||
c.Assert(err, qt.IsNil) | ||
c.Check(m.Life, qt.Equals, state.Dying.String()) | ||
}) | ||
} | ||
} | ||
|