Skip to content

Commit

Permalink
Merge pull request #9 from Hidayathamir/feature/source-to-store-code
Browse files Browse the repository at this point in the history
feat: source to store code
  • Loading branch information
hafizarr authored Mar 6, 2024
2 parents b9a3bd7 + d38d2ef commit 535289b
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 0 deletions.
7 changes: 7 additions & 0 deletions helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -275,3 +275,10 @@ func IsValidSource(source string) bool {

return false
}

func SourceToStoreCodeCCM(source string) (storeCode string) {
if source == constants.XSource_Enterprise {
return "en"
}
return source
}
35 changes: 35 additions & 0 deletions helper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import (
"fmt"
"reflect"
"testing"

"github.com/erajayatech/go-helper/constants"
)

func TestValidateStruct(t *testing.T) {
Expand Down Expand Up @@ -637,3 +639,36 @@ func TestIsSourcePaymentLink(t *testing.T) {
})
}
}

func TestSourceToStoreCodeCCM(t *testing.T) {
type args struct {
source string
}
tests := []struct {
name string
args args
wantStoreCode string
}{
{
name: "source enterprise should return en",
args: args{
source: constants.XSource_Enterprise,
},
wantStoreCode: "en",
},
{
name: "source except enterprise should return itself",
args: args{
source: constants.XSource_Eraspace,
},
wantStoreCode: constants.XSource_Eraspace,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if gotStoreCode := SourceToStoreCodeCCM(tt.args.source); gotStoreCode != tt.wantStoreCode {
t.Errorf("SourceToStoreCodeCCM() = %v, want %v", gotStoreCode, tt.wantStoreCode)
}
})
}
}

0 comments on commit 535289b

Please sign in to comment.