Skip to content

Commit

Permalink
Merge branch 'main' into goroutine-leak
Browse files Browse the repository at this point in the history
  • Loading branch information
youngbupark authored Jun 13, 2023
2 parents b2a8ad0 + a570971 commit ea3de58
Show file tree
Hide file tree
Showing 22 changed files with 132 additions and 327 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,20 @@ import (
)

func TestDaprInvokeHttpRoute_ConvertVersionedToDataModel(t *testing.T) {
testset := []string{"daprinvokehttprouteresource.json", "daprinvokehttprouteresource2.json", "daprinvokehttprouteresource_recipe.json"}
testset := []string{
"daprinvokehttprouteresource.json",
"daprinvokehttprouteresource2.json",
"daprinvokehttprouteresource_recipe.json",
}
for _, payload := range testset {
// arrange
rawPayload, err := loadTestData("./testdata/" + payload)
reader, err := loadTestDataAsReader("./testdata/" + payload)
require.NoError(t, err)

versionedResource := &DaprInvokeHTTPRouteResource{}
err = json.Unmarshal(rawPayload, versionedResource)
decoder := json.NewDecoder(reader)
decoder.DisallowUnknownFields()
err = decoder.Decode(versionedResource)
require.NoError(t, err)

// act
Expand Down
10 changes: 10 additions & 0 deletions pkg/linkrp/api/v20220315privatepreview/test_util.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ limitations under the License.
package v20220315privatepreview

import (
"bytes"
"io"
"os"
"time"
)
Expand All @@ -29,6 +31,14 @@ func loadTestData(testfile string) ([]byte, error) {
return d, nil
}

func loadTestDataAsReader(testfile string) (io.Reader, error) {
d, err := os.ReadFile(testfile)
if err != nil {
return nil, err
}
return bytes.NewReader(d), nil
}

func unmarshalTimeString(ts string) *time.Time {
var tt timeRFC3339
_ = tt.UnmarshalText([]byte(ts))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
},
"application": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Core/applications/testApplication",
"environment": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Core/environments/env0",
"mode": "recipe",
"recipe": {
"name": "recipe-test"
}
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ func TestListSecrets_20220315PrivatePreview(t *testing.T) {

require.NoError(t, err)
resp, err := ctl.Run(ctx, w, req)

require.NoError(t, err)
_ = resp.Apply(ctx, w, req)
require.Equal(t, 404, w.Result().StatusCode)
Expand Down Expand Up @@ -103,10 +104,11 @@ func TestListSecrets_20220315PrivatePreview(t *testing.T) {
}

ctl, err := NewListSecretsMongoDatabase(opts)

require.NoError(t, err)

resp, err := ctl.Run(ctx, w, req)
require.NoError(t, err)

_ = resp.Apply(ctx, w, req)
require.Equal(t, 200, w.Result().StatusCode)

Expand Down Expand Up @@ -145,10 +147,11 @@ func TestListSecrets_20220315PrivatePreview(t *testing.T) {
}

ctl, err := NewListSecretsMongoDatabase(opts)

require.NoError(t, err)

resp, err := ctl.Run(ctx, w, req)
require.NoError(t, err)

_ = resp.Apply(ctx, w, req)
require.Equal(t, 200, w.Result().StatusCode)

Expand Down Expand Up @@ -178,8 +181,8 @@ func TestListSecrets_20220315PrivatePreview(t *testing.T) {
}

ctl, err := NewListSecretsMongoDatabase(opts)

require.NoError(t, err)

_, err = ctl.Run(ctx, w, req)
require.Error(t, err)
})
Expand Down
Original file line number Diff line number Diff line change
@@ -1,44 +1,50 @@
{
"id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/applications.link/mongodatabases/mongo0",
"name": "mongo0",
"type": "applications.link/mongodatabases",
"location": "West US",
"systemData": {
"createdAt": "2022-03-22T18:54:52.6857175Z",
"createdBy": "fake@hotmail.com",
"createdByType": "User",
"lastModifiedAt": "2022-03-22T18:57:52.6857175Z",
"lastModifiedBy": "fake@hotmail.com",
"lastModifiedByType": "User"
"id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/applications.link/mongodatabases/mongo0",
"name": "mongo0",
"type": "applications.link/mongodatabases",
"location": "West US",
"systemData": {
"createdAt": "2022-03-22T18:54:52.6857175Z",
"createdBy": "fake@hotmail.com",
"createdByType": "User",
"lastModifiedAt": "2022-03-22T18:57:52.6857175Z",
"lastModifiedBy": "fake@hotmail.com",
"lastModifiedByType": "User"
},
"properties": {
"status": {
"outputResources": [
{
"LocalID": "AzureCosmosAccount",
"Dependencies": null,
"ResourceType": {
"type": "azure.cosmosdb.account",
"provider": "azure"
}
}
]
},
"properties": {
"status": {
"outputResources": [{
"LocalID": "AzureCosmosAccount",
"Dependencies": null,
"ResourceType": {
"type": "azure.cosmosdb.account",
"provider": "azure"
}
}]
},
"provisioningState": "Succeeded",
"application": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Core/applications/testApplication",
"environment": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Core/environments/env0",
"mode": "resource",
"resource": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Microsoft.DocumentDB/databaseAccounts/testAccount/mongodbDatabases/db",
"host": "testAccount1.mongo.cosmos.azure.com",
"port": 10255,
"secrets": {
"username": "testUser",
"password": "testPassword",
"connectionString": "mongodb://testUser:testPassword@testAccount1.mongo.cosmos.azure.com:10255"
},
"database": "db"
"provisioningState": "Succeeded",
"application": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Core/applications/testApplication",
"environment": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Core/environments/env0",
"resourceProvisioning": "manual",
"resources": [
{
"id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Microsoft.DocumentDB/databaseAccounts/testAccount/mongodbDatabases/db"
}
],
"host": "testAccount1.mongo.cosmos.azure.com",
"port": 10255,
"secrets": {
"username": "testUser",
"password": "testPassword",
"connectionString": "mongodb://testUser:testPassword@testAccount1.mongo.cosmos.azure.com:10255"
},
"tenantId": "00000000-0000-0000-0000-000000000000",
"subscriptionId": "00000000-0000-0000-0000-000000000000",
"resourceGroup": "radius-test-rg",
"createdApiVersion": "2022-03-15-privatepreview",
"updatedApiVersion": "2022-03-15-privatepreview"
"database": "db"
},
"tenantId": "00000000-0000-0000-0000-000000000000",
"subscriptionId": "00000000-0000-0000-0000-000000000000",
"resourceGroup": "radius-test-rg",
"createdApiVersion": "2022-03-15-privatepreview",
"updatedApiVersion": "2022-03-15-privatepreview"
}

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -27,17 +27,9 @@ import (
const testHeaderfile = "20220315privatepreview_requestheaders.json"

func getTestModels20220315privatepreview() (input *v20220315privatepreview.MongoDatabaseResource, dataModel *datamodel.MongoDatabase, output *v20220315privatepreview.MongoDatabaseResource) {
rawInput := testutil.ReadFixture("20220315privatepreview_input.json")
input = &v20220315privatepreview.MongoDatabaseResource{}
_ = json.Unmarshal(rawInput, input)

rawDataModel := testutil.ReadFixture("20220315privatepreview_datamodel.json")
dataModel = &datamodel.MongoDatabase{}
_ = json.Unmarshal(rawDataModel, dataModel)

rawExpectedOutput := testutil.ReadFixture("20220315privatepreview_output.json")
output = &v20220315privatepreview.MongoDatabaseResource{}
_ = json.Unmarshal(rawExpectedOutput, output)

return input, dataModel, output
}
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,11 @@ func TestListSecrets_20220315PrivatePreview(t *testing.T) {
}

ctl, err := NewListSecretsRabbitMQMessageQueue(opts)

require.NoError(t, err)

resp, err := ctl.Run(ctx, w, req)
require.NoError(t, err)

_ = resp.Apply(ctx, w, req)
require.Equal(t, 404, w.Result().StatusCode)
})
Expand Down Expand Up @@ -102,10 +103,11 @@ func TestListSecrets_20220315PrivatePreview(t *testing.T) {
}

ctl, err := NewListSecretsRabbitMQMessageQueue(opts)

require.NoError(t, err)

resp, err := ctl.Run(ctx, w, req)
require.NoError(t, err)

_ = resp.Apply(ctx, w, req)
require.Equal(t, 200, w.Result().StatusCode)

Expand Down Expand Up @@ -140,10 +142,11 @@ func TestListSecrets_20220315PrivatePreview(t *testing.T) {
}

ctl, err := NewListSecretsRabbitMQMessageQueue(opts)

require.NoError(t, err)

resp, err := ctl.Run(ctx, w, req)
require.NoError(t, err)

_ = resp.Apply(ctx, w, req)
require.Equal(t, 200, w.Result().StatusCode)

Expand Down Expand Up @@ -173,8 +176,8 @@ func TestListSecrets_20220315PrivatePreview(t *testing.T) {
}

ctl, err := NewListSecretsRabbitMQMessageQueue(opts)

require.NoError(t, err)

_, err = ctl.Run(ctx, w, req)
require.Error(t, err)
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"provisioningState": "Succeeded",
"environment": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Core/environments/env0",
"application": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Core/applications/testApplication",
"mode": "values",
"resourceProvisioning": "manual",
"queue": "testQueue",
"secrets": {
"connectionString": "connection://string"
Expand Down

This file was deleted.

This file was deleted.

Loading

0 comments on commit ea3de58

Please sign in to comment.