Skip to content

Commit

Permalink
test(HMS-4532): pendo client
Browse files Browse the repository at this point in the history
Add unit tests for pendo client.

Signed-off-by: Alejandro Visiedo <[email protected]>
  • Loading branch information
avisiedo authored and pvoborni committed Aug 14, 2024
1 parent 6093fd1 commit 7f1902b
Show file tree
Hide file tree
Showing 4 changed files with 485 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package pendo

import (
"github.com/podengo-project/idmsvc-backend/internal/interface/client/pendo"
pendo_api "github.com/podengo-project/idmsvc-backend/internal/interface/client/pendo"
)

type SetMetadataDetailsRequest interface {
Build() *pendo.SetMetadataDetailsRequest
SetVisitorID(value string) SetMetadataDetailsRequest
AddValue(fieldName string, value any) SetMetadataDetailsRequest
}

type setMetadataDetailsRequest pendo_api.SetMetadataDetailsRequest

func NewSetMetadataDetailsRequest() SetMetadataDetailsRequest {
return (*setMetadataDetailsRequest)(&pendo_api.SetMetadataDetailsRequest{})
}

func (b *setMetadataDetailsRequest) Build() *pendo.SetMetadataDetailsRequest {
return (*pendo.SetMetadataDetailsRequest)(b)
}

func (b *setMetadataDetailsRequest) SetVisitorID(value string) SetMetadataDetailsRequest {
b.VisitorID = value
return b
}

func (b *setMetadataDetailsRequest) AddValue(fieldName string, value any) SetMetadataDetailsRequest {
b.Values[fieldName] = value
return b
}
26 changes: 26 additions & 0 deletions internal/test/builder/clients/pendo/builder_setmetadatarequest.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package pendo

import (
"github.com/podengo-project/idmsvc-backend/internal/interface/client/pendo"
pendo_api "github.com/podengo-project/idmsvc-backend/internal/interface/client/pendo"
)

type SetMetadataRequest interface {
Add(item pendo.SetMetadataDetailsRequest) SetMetadataRequest
Build() *pendo.SetMetadataRequest
}

type setMetadataRequest pendo_api.SetMetadataRequest

func NewSetMetadataRequest() SetMetadataRequest {
return (*setMetadataRequest)(&pendo_api.SetMetadataRequest{})
}

func (b *setMetadataRequest) Build() *pendo.SetMetadataRequest {
return (*pendo.SetMetadataRequest)(b)
}

func (b *setMetadataRequest) Add(item pendo.SetMetadataDetailsRequest) SetMetadataRequest {
*b = append(*b, item)
return b
}
62 changes: 62 additions & 0 deletions internal/test/builder/clients/pendo/builder_setmetadataresponse.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
package pendo

import (
"github.com/podengo-project/idmsvc-backend/internal/interface/client/pendo"
pendo_api "github.com/podengo-project/idmsvc-backend/internal/interface/client/pendo"
)

type SetMetadataResponse interface {
Build() *pendo.SetMetadataResponse
WithTotal(value int64) SetMetadataResponse
WithUpdated(value int64) SetMetadataResponse
IncUpdated() SetMetadataResponse
WithFailed(value int64) SetMetadataResponse
IncFailed() SetMetadataResponse
AddMissing(value string) SetMetadataResponse
WithKind(value pendo.Kind) SetMetadataResponse
}

type setMetadataResponse pendo_api.SetMetadataResponse

func NewSetMetadataResponse() SetMetadataResponse {
return (*setMetadataResponse)(&pendo_api.SetMetadataResponse{})
}

func (b *setMetadataResponse) Build() *pendo.SetMetadataResponse {
return (*pendo.SetMetadataResponse)(b)
}

func (b *setMetadataResponse) WithTotal(value int64) SetMetadataResponse {
b.Total = value
return b
}

func (b *setMetadataResponse) WithUpdated(value int64) SetMetadataResponse {
b.Updated = value
return b
}

func (b *setMetadataResponse) IncUpdated() SetMetadataResponse {
b.Updated++
return b
}

func (b *setMetadataResponse) WithFailed(value int64) SetMetadataResponse {
b.Failed = value
return b
}

func (b *setMetadataResponse) IncFailed() SetMetadataResponse {
b.Failed++
return b
}

func (b *setMetadataResponse) AddMissing(value string) SetMetadataResponse {
b.Missing = append(b.Missing, value)
return b
}

func (b *setMetadataResponse) WithKind(value pendo.Kind) SetMetadataResponse {
b.Kind = value
return b
}
Loading

0 comments on commit 7f1902b

Please sign in to comment.