@@ -30,10 +30,12 @@ import (
3030 "testing"
3131 "time"
3232
33- uuid "github.com/google/uuid"
33+ "github.com/google/uuid"
3434 "github.com/stretchr/testify/assert"
3535 "github.com/stretchr/testify/require"
36+ "google.golang.org/protobuf/proto"
3637
38+ "github.com/dapr/components-contrib/common/proto/state/sqlserver"
3739 "github.com/dapr/components-contrib/metadata"
3840 "github.com/dapr/components-contrib/state"
3941 "github.com/dapr/kit/logger"
@@ -42,7 +44,7 @@ import (
4244const (
4345 // connectionStringEnvKey defines the key containing the integration test connection string
4446 // To use docker, server=localhost;user id=sa;password=Pass@Word1;port=1433;
45- // To use Azure SQL, server=<your-db-server-name>.database.windows.net;user id=<your-db-user>;port=1433;password=<your-password>;database=dapr_test;.
47+ // To use Azure SQL, server=<your-db-server-name>.database.windows.net;User id=<your-db-user>;port=1433;password=<your-password>;database=dapr_test;.
4648 connectionStringEnvKey = "DAPR_TEST_SQL_CONNSTRING"
4749 usersTableName = "Users"
4850 beverageTea = "tea"
@@ -77,6 +79,7 @@ func TestIntegrationCases(t *testing.T) {
7779 t .Run ("Multi operations" , testMultiOperations )
7880 t .Run ("Insert and Update Set Record Dates" , testInsertAndUpdateSetRecordDates )
7981 t .Run ("Multiple initializations" , testMultipleInitializations )
82+ t .Run ("Should preserve byte data when not base64 encoded" , testNonBase64ByteData )
8083
8184 // Run concurrent set tests 10 times
8285 const executions = 10
@@ -112,6 +115,9 @@ func createMetadata(schema string, kt KeyType, indexedProperties string) state.M
112115
113116// Ensure the database is running
114117// For docker, use: docker run --name sqlserver -e "ACCEPT_EULA=Y" -e "SA_PASSWORD=Pass@Word1" -p 1433:1433 -d mcr.microsoft.com/mssql/server:2019-GA-ubuntu-16.04.
118+ // For azure-sql-edge use:
119+ // docker volume create sqlvolume
120+ // docker run --name sqlserver -e "ACCEPT_EULA=Y" -e "MSSQL_SA_PASSWORD=Pass@Word1" -e "MSSQL_PID=Developer" -e "MSSQL_AGENT_ENABLED=TRUE" -e "MSSQL_COLLATION=SQL_Latin1_General_CP1_CI_AS" -e "MSSQL_LCID=1033" -p 1433:1433 -v sqlvolume:/var/opt/mssql -d mcr.microsoft.com/azure-sql-edge:latest
115121func getTestStore (t * testing.T , indexedProperties string ) * SQLServer {
116122 return getTestStoreWithKeyType (t , StringKeyType , indexedProperties )
117123}
@@ -597,3 +603,23 @@ func testMultipleInitializations(t *testing.T) {
597603 })
598604 }
599605}
606+
607+ func testNonBase64ByteData (t * testing.T ) {
608+ t .Run ("Set And Get" , func (t * testing.T ) {
609+ store := getTestStore (t , "" )
610+ request := & sqlserver.TestEvent {
611+ EventId : - 1 ,
612+ }
613+ requestBytes , err := proto .Marshal (request )
614+ require .NoError (t , err )
615+ require .NoError (t , store .Set (t .Context (), & state.SetRequest {Key : "1" , Value : requestBytes }))
616+ resp , err := store .Get (t .Context (), & state.GetRequest {Key : "1" })
617+ require .NoError (t , err )
618+
619+ response := & sqlserver.TestEvent {}
620+ err = proto .Unmarshal (resp .Data , response )
621+ require .NoError (t , err )
622+
623+ assert .EqualValues (t , request .GetEventId (), response .GetEventId ())
624+ })
625+ }
0 commit comments