Skip to content

Commit

Permalink
[Tables] Update from testframework -> recording (#14888)
Browse files Browse the repository at this point in the history
* Initial generation of the aztables module (#14441)

* initial generation

* Update ci.yml

* Introduce internal/testFramework and test aztables with it (#14491)

* testFramework initial implementation

* sanitizer fixes (#14600)

* Progress on aztables (#14676)

* implement batch operations and all entity operations

* AsModels

* rename

* comments

* comment tweaks, options as pointer

* add EntityMapAsModel

* refactors to AddEntity

* update some code docs

* doc fixes

* doc fixes

* doc improvements

* rename testframework to recording

* fixing tables to go from testframework -> recording

* renaming recordingInstance -> r

* file name change

Co-authored-by: Christopher Scott <chriss@microsoft.com>
Co-authored-by: catalinaperalta <catalinaperaltah@hotmail.com>
  • Loading branch information
3 people authored Jun 30, 2021
1 parent f2d1250 commit 274d7ac
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 22 deletions.
15 changes: 15 additions & 0 deletions sdk/tables/aztable/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# NOTE: Please refer to https://aka.ms/azsdk/engsys/ci-yaml before editing this file.
trigger:
paths:
include:
- sdk/tables/aztable/

pr:
paths:
include:
- sdk/tables/aztable/

stages:
- template: ../../../eng/pipelines/templates/jobs/archetype-sdk-client.yml
parameters:
ServiceDirectory: 'tables'
8 changes: 4 additions & 4 deletions sdk/tables/aztable/table_client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ import (
"testing"
"time"

"github.com/Azure/azure-sdk-for-go/sdk/internal/recording"
"github.com/Azure/azure-sdk-for-go/sdk/internal/runtime"
"github.com/Azure/azure-sdk-for-go/sdk/internal/testframework"
"github.com/Azure/azure-sdk-for-go/sdk/internal/uuid"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
Expand All @@ -22,18 +22,18 @@ import (
type tableClientLiveTests struct {
suite.Suite
endpointType EndpointType
mode testframework.RecordMode
mode recording.RecordMode
}

// Hookup to the testing framework
func TestTableClient_Storage(t *testing.T) {
storage := tableClientLiveTests{endpointType: StorageEndpoint, mode: testframework.Playback /* change to Record to re-record tests */}
storage := tableClientLiveTests{endpointType: StorageEndpoint, mode: recording.Playback /* change to Record to re-record tests */}
suite.Run(t, &storage)
}

// Hookup to the testing framework
func TestTableClient_Cosmos(t *testing.T) {
cosmos := tableClientLiveTests{endpointType: CosmosEndpoint, mode: testframework.Playback /* change to Record to re-record tests */}
cosmos := tableClientLiveTests{endpointType: CosmosEndpoint, mode: recording.Playback /* change to Record to re-record tests */}
suite.Run(t, &cosmos)
}

Expand Down
8 changes: 4 additions & 4 deletions sdk/tables/aztable/table_service_client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,27 +9,27 @@ import (
"net/http"
"testing"

"github.com/Azure/azure-sdk-for-go/sdk/internal/recording"
"github.com/Azure/azure-sdk-for-go/sdk/internal/runtime"
"github.com/Azure/azure-sdk-for-go/sdk/internal/testframework"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/suite"
)

type tableServiceClientLiveTests struct {
suite.Suite
endpointType EndpointType
mode testframework.RecordMode
mode recording.RecordMode
}

// Hookup to the testing framework
func TestServiceClient_Storage(t *testing.T) {
storage := tableServiceClientLiveTests{endpointType: StorageEndpoint, mode: testframework.Playback /* change to Record to re-record tests */}
storage := tableServiceClientLiveTests{endpointType: StorageEndpoint, mode: recording.Playback /* change to Record to re-record tests */}
suite.Run(t, &storage)
}

// Hookup to the testing framework
func TestServiceClient_Cosmos(t *testing.T) {
cosmos := tableServiceClientLiveTests{endpointType: CosmosEndpoint, mode: testframework.Playback /* change to Record to re-record tests */}
cosmos := tableServiceClientLiveTests{endpointType: CosmosEndpoint, mode: recording.Playback /* change to Record to re-record tests */}
suite.Run(t, &cosmos)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,16 @@ import (
"time"

"github.com/Azure/azure-sdk-for-go/sdk/azcore"
"github.com/Azure/azure-sdk-for-go/sdk/internal/testframework"
"github.com/Azure/azure-sdk-for-go/sdk/internal/recording"
"github.com/stretchr/testify/assert"
)

type tablesRecordedTests struct{}

type testContext struct {
recording *testframework.Recording
recording *recording.Recording
client *TableServiceClient
context *testframework.TestContext
context *recording.TestContext
}

const (
Expand Down Expand Up @@ -54,7 +54,7 @@ func cosmosURI(accountName string, endpointSuffix string) string {
}

// create the test specific TableClient and wire it up to recordings
func recordedTestSetup(t *testing.T, testName string, endpointType EndpointType, mode testframework.RecordMode) {
func recordedTestSetup(t *testing.T, testName string, endpointType EndpointType, mode recording.RecordMode) {
var accountName string
var suffix string
var cred *SharedKeyCredential
Expand All @@ -63,27 +63,27 @@ func recordedTestSetup(t *testing.T, testName string, endpointType EndpointType,
assert := assert.New(t)

// init the test framework
context := testframework.NewTestContext(func(msg string) { assert.FailNow(msg) }, func(msg string) { t.Log(msg) }, func() string { return testName })
recording, err := testframework.NewRecording(context, mode)
context := recording.NewTestContext(func(msg string) { assert.FailNow(msg) }, func(msg string) { t.Log(msg) }, func() string { return testName })
r, err := recording.NewRecording(context, mode)
assert.Nil(err)

if endpointType == StorageEndpoint {
accountName, err = recording.GetRecordedVariable(storageAccountNameEnvVar, testframework.Default)
suffix = recording.GetOptionalRecordedVariable(storageEndpointSuffixEnvVar, DefaultStorageSuffix, testframework.Default)
secret, err = recording.GetRecordedVariable(storageAccountKeyEnvVar, testframework.Secret_Base64String)
accountName, err = r.GetRecordedVariable(storageAccountNameEnvVar, recording.Default)
suffix = r.GetOptionalRecordedVariable(storageEndpointSuffixEnvVar, DefaultStorageSuffix, recording.Default)
secret, err = r.GetRecordedVariable(storageAccountKeyEnvVar, recording.Secret_Base64String)
cred, _ = NewSharedKeyCredential(accountName, secret)
uri = storageURI(accountName, suffix)
} else {
accountName, err = recording.GetRecordedVariable(cosmosAccountNameEnnVar, testframework.Default)
suffix = recording.GetOptionalRecordedVariable(cosmosEndpointSuffixEnvVar, DefaultCosmosSuffix, testframework.Default)
secret, err = recording.GetRecordedVariable(cosmosAccountKeyEnvVar, testframework.Secret_Base64String)
accountName, err = r.GetRecordedVariable(cosmosAccountNameEnnVar, recording.Default)
suffix = r.GetOptionalRecordedVariable(cosmosEndpointSuffixEnvVar, DefaultCosmosSuffix, recording.Default)
secret, err = r.GetRecordedVariable(cosmosAccountKeyEnvVar, recording.Secret_Base64String)
cred, _ = NewSharedKeyCredential(accountName, secret)
uri = cosmosURI(accountName, suffix)
}

client, err := NewTableServiceClient(uri, cred, &TableClientOptions{HTTPClient: recording, Retry: azcore.RetryOptions{MaxRetries: -1}})
client, err := NewTableServiceClient(uri, cred, &TableClientOptions{HTTPClient: r, Retry: azcore.RetryOptions{MaxRetries: -1}})
assert.Nil(err)
clientsMap[testName] = &testContext{client: client, recording: recording, context: &context}
clientsMap[testName] = &testContext{client: client, recording: r, context: &context}
}

func recordedTestTeardown(key string) {
Expand Down

0 comments on commit 274d7ac

Please sign in to comment.