Add GetID() to model.BaseModel (#1336)

## Type of change

- [x] 🐹 Trivial/Minor

## Issue(s)

* #1334

## Test Plan

- [x]  Unit test
This commit is contained in:
Keepers 2022-10-25 17:46:49 -06:00 committed by GitHub
parent efd697f522
commit 8ddbc16077
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 0 deletions

View File

@ -61,3 +61,8 @@ type BaseModel struct {
func (bm *BaseModel) Base() *BaseModel {
return bm
}
// GetID returns the baseModel.ID as a string rather than a model.StableID.
func (bm *BaseModel) GetID() string {
return string(bm.ID)
}

View File

@ -3,6 +3,7 @@ package model_test
import (
"testing"
"github.com/google/uuid"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/suite"
@ -36,3 +37,11 @@ func (suite *ModelUnitSuite) TestValid() {
})
}
}
func (suite *ModelUnitSuite) TestGetID() {
bm := model.BaseModel{
ID: model.StableID(uuid.NewString()),
}
assert.Equal(suite.T(), string(bm.ID), bm.GetID())
}