Skip to content

Commit 1e24281

Browse files
committed
Expose default namespace name
1 parent 30b6850 commit 1e24281

11 files changed

+19
-19
lines changed

backstage/backstage.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@ type service struct {
1616
}
1717

1818
const (
19+
DefaultNamespaceName = "default"
1920
userAgent = "go-backstage"
2021
contentTypeJSON = "application/json"
21-
defaultNamespaceName = "default"
2222
)
2323

2424
// Client manages communication with the Backstage API.
@@ -60,7 +60,7 @@ func NewClient(baseURL string, defaultNamespace string, httpClient *http.Client)
6060

6161
ns := defaultNamespace
6262
if defaultNamespace == "" {
63-
ns = defaultNamespaceName
63+
ns = DefaultNamespaceName
6464
}
6565

6666
c := &Client{

backstage/backstage_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ func TestNewClient_NoApiSuffix(t *testing.T) {
3636

3737
assert.NoError(t, err, "New client should not return an error")
3838
assert.Equal(t, baseURL+"/api", c.BaseURL.String(), "Base URL should match the one provided")
39-
assert.Equal(t, "default", c.DefaultNamespace, "Default namespace should be 'default'")
39+
assert.Equal(t, DefaultNamespaceName, c.DefaultNamespace, "Default namespace should be 'default'")
4040
}
4141

4242
// TestNewClient tests the creation of a new Backstage client from an existing HTTP client.
@@ -72,7 +72,7 @@ func TestNewClient_DefaultNamespace(t *testing.T) {
7272
c, err := NewClient("http://localhost:7007/api/", "", nil)
7373

7474
assert.NoError(t, err, "New client should not return an error")
75-
assert.Equal(t, defaultNamespaceName, c.DefaultNamespace, "Default namespace should be set to default if not provided")
75+
assert.Equal(t, DefaultNamespaceName, c.DefaultNamespace, "Default namespace should be set to default if not provided")
7676
}
7777

7878
// TestNewRequest_Get tests the creation of a new GET request.

backstage/entity_test.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ func TestEntityServiceGet(t *testing.T) {
3333
Reply(200).
3434
File(dataFile)
3535

36-
c, _ := NewClient(baseURL.String(), "default", nil)
36+
c, _ := NewClient(baseURL.String(), "", nil)
3737
s := newEntityService(newCatalogService(c))
3838

3939
actual, resp, err := s.Get(context.Background(), uid)
@@ -62,7 +62,7 @@ func TestEntityServiceList(t *testing.T) {
6262
Reply(200).
6363
File(dataFile)
6464

65-
c, _ := NewClient(baseURL.String(), "default", nil)
65+
c, _ := NewClient(baseURL.String(), "", nil)
6666
s := newEntityService(newCatalogService(c))
6767

6868
actual, resp, err := s.List(context.Background(), nil)
@@ -92,7 +92,7 @@ func TestEntityServiceList_Filter(t *testing.T) {
9292
Reply(200).
9393
File(dataFile)
9494

95-
c, _ := NewClient(baseURL.String(), "default", nil)
95+
c, _ := NewClient(baseURL.String(), "", nil)
9696
s := newEntityService(newCatalogService(c))
9797

9898
actual, resp, err := s.List(context.Background(), &ListEntityOptions{
@@ -125,7 +125,7 @@ func TestEntityServiceList_Fields(t *testing.T) {
125125
Reply(200).
126126
File(dataFile)
127127

128-
c, _ := NewClient(baseURL.String(), "default", nil)
128+
c, _ := NewClient(baseURL.String(), "", nil)
129129
s := newEntityService(newCatalogService(c))
130130

131131
actual, resp, err := s.List(context.Background(), &ListEntityOptions{
@@ -159,7 +159,7 @@ func TestEntityServiceList_Order(t *testing.T) {
159159
Reply(200).
160160
File(dataFile)
161161

162-
c, _ := NewClient(baseURL.String(), "default", nil)
162+
c, _ := NewClient(baseURL.String(), "", nil)
163163
s := newEntityService(newCatalogService(c))
164164

165165
actual, resp, err := s.List(context.Background(), &ListEntityOptions{
@@ -178,7 +178,7 @@ func TestEntityServiceList_Order(t *testing.T) {
178178

179179
// TestEntityServiceList_InvalidOrder tests the retrieval of a list when invalid order is provided.
180180
func TestEntityServiceList_InvalidOrder(t *testing.T) {
181-
c, _ := NewClient("", "default", nil)
181+
c, _ := NewClient("", "", nil)
182182
s := newEntityService(newCatalogService(c))
183183

184184
_, _, err := s.List(context.Background(), &ListEntityOptions{
@@ -204,7 +204,7 @@ func TestEntityServiceDelete(t *testing.T) {
204204
Delete(fmt.Sprintf("/catalog/entities/by-uid/%s", uid)).
205205
Reply(http.StatusNoContent)
206206

207-
c, _ := NewClient(baseURL.String(), "default", nil)
207+
c, _ := NewClient(baseURL.String(), "", nil)
208208
s := newEntityService(newCatalogService(c))
209209

210210
resp, err := s.Delete(context.Background(), "uid")

backstage/kind_api_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ func TestKindApiGet(t *testing.T) {
3232
Reply(200).
3333
File(dataFile)
3434

35-
c, _ := NewClient(baseURL.String(), "default", nil)
35+
c, _ := NewClient(baseURL.String(), "", nil)
3636
s := newApiService(&entityService{
3737
client: c,
3838
apiPath: "/catalog/entities",

backstage/kind_component_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ func TestKindComponentGet(t *testing.T) {
3232
Reply(200).
3333
File(dataFile)
3434

35-
c, _ := NewClient(baseURL.String(), "default", nil)
35+
c, _ := NewClient(baseURL.String(), "", nil)
3636
s := newComponentService(&entityService{
3737
client: c,
3838
apiPath: "/catalog/entities",

backstage/kind_domain_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ func TestKindDomainGet(t *testing.T) {
3232
Reply(200).
3333
File(dataFile)
3434

35-
c, _ := NewClient(baseURL.String(), "default", nil)
35+
c, _ := NewClient(baseURL.String(), "", nil)
3636
s := newDomainService(&entityService{
3737
client: c,
3838
apiPath: "/catalog/entities",

backstage/kind_group_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ func TestKindGroupGet(t *testing.T) {
3232
Reply(200).
3333
File(dataFile)
3434

35-
c, _ := NewClient(baseURL.String(), "default", nil)
35+
c, _ := NewClient(baseURL.String(), "", nil)
3636
s := newGroupService(&entityService{
3737
client: c,
3838
apiPath: "/catalog/entities",

backstage/kind_location_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ func TestKindLocationGet(t *testing.T) {
3232
Reply(200).
3333
File(dataFile)
3434

35-
c, _ := NewClient(baseURL.String(), "default", nil)
35+
c, _ := NewClient(baseURL.String(), "", nil)
3636
s := newLocationService(&entityService{
3737
client: c,
3838
apiPath: "/catalog/entities",

backstage/kind_resource_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ func TestKindResourceGet(t *testing.T) {
3232
Reply(200).
3333
File(dataFile)
3434

35-
c, _ := NewClient(baseURL.String(), "default", nil)
35+
c, _ := NewClient(baseURL.String(), "", nil)
3636
s := newResourceService(&entityService{
3737
client: c,
3838
apiPath: "/catalog/entities",

backstage/kind_system_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ func TestKindSystemGet(t *testing.T) {
3232
Reply(200).
3333
File(dataFile)
3434

35-
c, _ := NewClient(baseURL.String(), "default", nil)
35+
c, _ := NewClient(baseURL.String(), "", nil)
3636
s := newSystemService(&entityService{
3737
client: c,
3838
apiPath: "/catalog/entities",

0 commit comments

Comments
 (0)