From 8ddbc16077b6efa24055be29e37c2d0195e1ce0b Mon Sep 17 00:00:00 2001 From: Keepers Date: Tue, 25 Oct 2022 17:46:49 -0600 Subject: [PATCH] Add GetID() to model.BaseModel (#1336) ## Type of change - [x] :hamster: Trivial/Minor ## Issue(s) * #1334 ## Test Plan - [x] :zap: Unit test --- src/internal/model/model.go | 5 +++++ src/internal/model/model_test.go | 9 +++++++++ 2 files changed, 14 insertions(+) diff --git a/src/internal/model/model.go b/src/internal/model/model.go index 5542ff9d8..b0e906010 100644 --- a/src/internal/model/model.go +++ b/src/internal/model/model.go @@ -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) +} diff --git a/src/internal/model/model_test.go b/src/internal/model/model_test.go index d55cffafb..d0fc0f81d 100644 --- a/src/internal/model/model_test.go +++ b/src/internal/model/model_test.go @@ -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()) +}