1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60
|
package telemetry
import (
"testing"
)
type MockCheckRequestTupleKey struct {
user *string
}
func (m *MockCheckRequestTupleKey) GetUser() *string {
return m.user
}
type MockRequestAuthorizationModelId struct {
authorizationModelId *string
}
func (m *MockRequestAuthorizationModelId) GetAuthorizationModelId() *string {
return m.authorizationModelId
}
type MockCheckRequest struct {
MockCheckRequestTupleKey
MockRequestAuthorizationModelId
}
func (m *MockCheckRequest) GetTupleKey() *MockCheckRequestTupleKey {
return &m.MockCheckRequestTupleKey
}
func TestCheckRequestInterfaceImplementation(t *testing.T) {
user := "test-user"
modelId := "test-model-id"
mockCheckRequest := &MockCheckRequest{
MockCheckRequestTupleKey: MockCheckRequestTupleKey{user: &user},
MockRequestAuthorizationModelId: MockRequestAuthorizationModelId{authorizationModelId: &modelId},
}
if mockCheckRequest.GetTupleKey().GetUser() != &user {
t.Errorf("Expected GetUser to return '%s', but got '%s'", user, *mockCheckRequest.GetTupleKey().GetUser())
}
if mockCheckRequest.GetAuthorizationModelId() != &modelId {
t.Errorf("Expected GetAuthorizationModelId to return '%s', but got '%s'", modelId, *mockCheckRequest.GetAuthorizationModelId())
}
}
func TestCheckRequestInterfaceNilValues(t *testing.T) {
mockCheckRequest := &MockCheckRequest{}
if mockCheckRequest.GetTupleKey().GetUser() != nil {
t.Errorf("Expected GetUser to return nil, but got '%s'", *mockCheckRequest.GetTupleKey().GetUser())
}
if mockCheckRequest.GetAuthorizationModelId() != nil {
t.Errorf("Expected GetAuthorizationModelId to return nil, but got '%s'", *mockCheckRequest.GetAuthorizationModelId())
}
}
|