This repository was archived by the owner on Apr 13, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 16
[FEATURE] Get subscription id in spk setup command #386
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
5135f7f
[FEATURE] Get subscription id in spk setup command
dennisseah 596ce8f
fix typo and test
dennisseah 22f5308
fix typo
dennisseah 57183e6
Merge branch 'master' into issue1138
dennisseah ab1efdd
Merge branch 'master' into issue1138
dennisseah File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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,69 @@ | ||
import { | ||
Subscription, | ||
SubscriptionClientOptions | ||
} from "@azure/arm-subscriptions/src/models"; | ||
import { ApplicationTokenCredentials } from "@azure/ms-rest-nodeauth"; | ||
import * as restAuth from "@azure/ms-rest-nodeauth"; | ||
import { getSubscriptions } from "./subscriptionService"; | ||
|
||
jest.mock("@azure/arm-subscriptions", () => { | ||
class MockClient { | ||
constructor( | ||
cred: ApplicationTokenCredentials, | ||
options?: SubscriptionClientOptions | ||
) { | ||
return { | ||
subscriptions: { | ||
list: () => { | ||
return [ | ||
{ | ||
displayName: "test", | ||
subscriptionId: "1234567890-abcdef" | ||
} | ||
]; | ||
} | ||
} | ||
}; | ||
} | ||
} | ||
return { | ||
SubscriptionClient: MockClient | ||
}; | ||
}); | ||
|
||
describe("test getSubscriptions function", () => { | ||
it("positive test: one value", async () => { | ||
jest | ||
.spyOn(restAuth, "loginWithServicePrincipalSecret") | ||
.mockImplementationOnce(async () => { | ||
return {}; | ||
}); | ||
const result = await getSubscriptions({ | ||
accessToken: "pat", | ||
orgName: "org", | ||
projectName: "project", | ||
workspace: "test" | ||
}); | ||
expect(result).toStrictEqual([ | ||
{ | ||
id: "1234567890-abcdef", | ||
name: "test" | ||
} | ||
]); | ||
}); | ||
it("negative test", async () => { | ||
jest | ||
.spyOn(restAuth, "loginWithServicePrincipalSecret") | ||
.mockImplementationOnce(async () => { | ||
throw Error("fake"); | ||
}); | ||
await expect( | ||
getSubscriptions({ | ||
accessToken: "pat", | ||
orgName: "org", | ||
projectName: "project", | ||
workspace: "test" | ||
}) | ||
).rejects.toThrow(); | ||
}); | ||
}); |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.