Skip to content
This repository has been archived by the owner on Jul 11, 2023. It is now read-only.

Commit

Permalink
service: Simplify and test MeshService.FQDN() (#3826)
Browse files Browse the repository at this point in the history
* service: Simplify and test MeshService.FQDN()

Signed-off-by: Delyan Raychev <[email protected]>
  • Loading branch information
draychev authored Jul 21, 2021
1 parent 94394bd commit b370fa2
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
3 changes: 1 addition & 2 deletions pkg/service/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package service

import (
"fmt"
"strings"

"github.com/openservicemesh/osm/pkg/constants"
"github.com/openservicemesh/osm/pkg/identity"
Expand Down Expand Up @@ -56,7 +55,7 @@ func (ms MeshService) FQDN() string {
if ms.ClusterDomain == "" {
ms.ClusterDomain = constants.LocalDomain
}
return strings.Join([]string{ms.Name, ms.Namespace, ms.ClusterDomain.String()}, ".")
return fmt.Sprintf("%s.%s.%s", ms.Name, ms.Namespace, ms.ClusterDomain)
}

// Local returns whether or not this is service is in the local cluster.
Expand Down
8 changes: 6 additions & 2 deletions pkg/service/types_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ var _ = Describe("Test pkg/service functions", func() {
})
})

Context("Test MeshService's String method", func() {
Context("Test MeshService's String and FQDN methods", func() {
namespace := uuid.New().String()
name := uuid.New().String()
ms := MeshService{
Expand All @@ -32,9 +32,13 @@ var _ = Describe("Test pkg/service functions", func() {
ClusterDomain: constants.LocalDomain,
}

It("implements stringer correctly", func() {
It("implements String() correctly", func() {
Expect(ms.String()).To(Equal(fmt.Sprintf("%s/%s/%s", namespace, name, constants.LocalDomain)))
})

It("implements FQDN() correctly", func() {
Expect(ms.FQDN()).To(Equal(fmt.Sprintf("%s.%s.%s", name, namespace, constants.LocalDomain)))
})
})

})

0 comments on commit b370fa2

Please sign in to comment.