Skip to content
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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add utility functions for unit testing #5225

Merged
merged 1 commit into from
Mar 30, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
39 changes: 39 additions & 0 deletions ibm/unittest/utils.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
// Copyright IBM Corp. 2024 All Rights Reserved.
// Licensed under the Mozilla Public License v2.0

package unittest

import (
"github.com/IBM/go-sdk-core/v5/core"
"github.com/go-openapi/strfmt"
)

//
// Utility functions used by the resource/data source unit tests.
//

func CreateMockUUID(mockData string) *strfmt.UUID {
uuid := strfmt.UUID(mockData)
return &uuid
}

func CreateMockByteArray(mockData string) *[]byte {
ba := []byte(mockData)
return &ba
}

func CreateMockDate(mockData string) *strfmt.Date {
d, err := core.ParseDate(mockData)
if err != nil {
return nil
}
return &d
}

func CreateMockDateTime(mockData string) *strfmt.DateTime {
d, err := core.ParseDateTime(mockData)
if err != nil {
return nil
}
return &d
}