-
Notifications
You must be signed in to change notification settings - Fork 18
[Backend API] Implement endpoint for create event details #213 #281
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 41 commits
e93e518
b507d99
75d7042
f4172b7
b94bd2c
45b8e0c
eaa6972
290d971
9177a70
9ad61bf
b729ad0
c158308
9b82301
954c43e
419a973
30e911c
f17bd29
719d973
a521674
ec396dd
b6f66f2
ada1f22
9385d2f
69f35d3
17c9799
9548f5f
9b50e75
ca183e0
1c6c2d6
9bef6ab
a836420
7a7d848
55db6d6
473da19
2b466c7
d77ca2c
3f4b1e1
74d9674
9516436
a083391
6274ead
bbdbd68
0ff2663
f695a7c
4b5a1bd
78ffc92
e503167
1988f7f
2587bd6
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,30 @@ | ||
{ | ||
"Logging": { | ||
"LogLevel": { | ||
"Default": "Information", | ||
"Microsoft.AspNetCore": "Warning" | ||
} | ||
}, | ||
|
||
"Azure": { | ||
"OpenAI": { | ||
"Instances": [ | ||
{ | ||
"Endpoint": "https://{{location}}.api.cognitive.microsoft.com/", | ||
"ApiKey": "{{api-key}}", | ||
"DeploymentNames": [ | ||
"deployment-name-1", | ||
"deployment-name-2" | ||
] | ||
} | ||
] | ||
}, | ||
"KeyVault": { | ||
"VaultUri": "https://{{key-vault-name}}.vault.azure.net/", | ||
"SecretName": "azure-openai-instances" | ||
} | ||
} | ||
} | ||
{ | ||
"Logging": { | ||
"LogLevel": { | ||
"Default": "Information", | ||
"Microsoft.AspNetCore": "Warning" | ||
} | ||
}, | ||
|
||
"Azure": { | ||
"OpenAI": { | ||
"Instances": [ | ||
{ | ||
"Endpoint": "https://{{location}}.api.cognitive.microsoft.com/", | ||
"ApiKey": "{{api-key}}", | ||
"DeploymentNames": [ | ||
"deployment-name-1", | ||
"deployment-name-2" | ||
] | ||
} | ||
] | ||
}, | ||
"KeyVault": { | ||
"VaultUri": "https://{{key-vault-name}}.vault.azure.net/", | ||
"SecretNames": { | ||
"OpenAI": "azure-openai-instances", | ||
"Storage": "storage-connection-string" | ||
} | ||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -37,7 +37,7 @@ | |
var tableServiceClient = default(TableServiceClient); | ||
|
||
// Act | ||
Action action = () => new AdminEventRepository(tableServiceClient, settings); | ||
Check warning on line 40 in test/AzureOpenAIProxy.ApiApp.Tests/Repositories/AdminEventRepositoryTests.cs
|
||
|
||
// Assert | ||
action.Should().Throw<ArgumentNullException>(); | ||
|
@@ -51,26 +51,53 @@ | |
var tableServiceClient = Substitute.For<TableServiceClient>(); | ||
|
||
// Act | ||
Action action = () => new AdminEventRepository(tableServiceClient, settings); | ||
Check warning on line 54 in test/AzureOpenAIProxy.ApiApp.Tests/Repositories/AdminEventRepositoryTests.cs
|
||
|
||
// Assert | ||
action.Should().Throw<ArgumentNullException>(); | ||
} | ||
|
||
[Fact] | ||
public void Given_Instance_When_CreateEvent_Invoked_Then_It_Should_Throw_Exception() | ||
public async Task Given_Instance_When_CreateEvent_Invoked_Then_It_Should_Return_Same_Instance() | ||
{ | ||
// Arrange | ||
var settings = Substitute.For<StorageAccountSettings>(); | ||
var tableServiceClient = Substitute.For<TableServiceClient>(); | ||
var tableClient = Substitute.For<TableClient>(); | ||
tableServiceClient.GetTableClient(Arg.Any<string>()).Returns(tableClient); | ||
tableClient.AddEntityAsync<AdminEventDetails>(Arg.Any<AdminEventDetails>()) | ||
.Returns(Task.FromResult(default(Response))); | ||
var eventDetails = new AdminEventDetails(); | ||
var repository = new AdminEventRepository(tableServiceClient, settings); | ||
|
||
// Act | ||
var result = await repository.CreateEvent(eventDetails); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 이게 동작하나요???? https://learn.microsoft.com/en-us/dotnet/azure/sdk/unit-testing-mocking?tabs=nsubstitute 만약에 동작한다면, 그건 그것대로 문제 같은데... 왜냐면 목킹이 제대로 안 된 것 같아서;;; There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 오.....! ㅠㅠㅠ 보내주신 문서보고 다시 해보겠습니다 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. (수정내용) (테스트목표) (궁금한점) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
단위테스트는 내가 테스트하고자 하는 메소드가 예를 들어서 지금과 같이 또한가지는 만약에 정리하자면 우리가 테스트하려는 대상은 |
||
|
||
// Assert | ||
result.Should().BeSameAs(eventDetails); | ||
} | ||
|
||
[Fact] | ||
public async Task Given_Failure_In_Add_Entity_When_CreateEvent_Invoked_Then_It_Should_Throw_Exception() | ||
{ | ||
// Arrange | ||
var settings = Substitute.For<StorageAccountSettings>(); | ||
var tableServiceClient = Substitute.For<TableServiceClient>(); | ||
var repository = new AdminEventRepository(tableServiceClient, settings); | ||
var eventDetails = new AdminEventDetails(); | ||
|
||
var exception = new InvalidOperationException("Invalid Operation Error : check duplicate, null or empty values"); | ||
|
||
var tableClient = Substitute.For<TableClient>(); | ||
tableServiceClient.GetTableClient(Arg.Any<string>()).Returns(tableClient); | ||
tableClient.AddEntityAsync<AdminEventDetails>(Arg.Any<AdminEventDetails>()) | ||
.ThrowsAsync(exception); | ||
|
||
// Act | ||
Func<Task> func = async () => await repository.CreateEvent(eventDetails); | ||
Func<Task> func = () => repository.CreateEvent(eventDetails); | ||
|
||
// Assert | ||
func.Should().ThrowAsync<NotImplementedException>(); | ||
await func.Should().ThrowAsync<InvalidOperationException>(); | ||
} | ||
|
||
[Fact] | ||
|
Uh oh!
There was an error while loading. Please reload this page.