-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
14b3758
commit f4fc813
Showing
2 changed files
with
144 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
// Copyright (c) 2023 Target Brands, Inc. All rights reserved. | ||
// | ||
// Use of this source code is governed by the LICENSE file in this repository. | ||
|
||
package library | ||
|
||
// QueueRegistration is the library representation of a QueueRegistration. | ||
// | ||
// swagger:model QueueRegistration | ||
type QueueRegistration struct { | ||
QueuePublicKey *string `json:"queue-public-key,omitempty"` | ||
QueueAddress *string `json:"queue-address,omitempty"` | ||
} | ||
|
||
// GetPublicKey returns the ID field. | ||
// | ||
// When the provided Worker type is nil, or the field within | ||
// the type is nil, it returns the zero value for the field. | ||
func (q *QueueRegistration) GetPublicKey() string { | ||
// return zero value if Worker type or ID field is nil | ||
if q == nil || q.QueuePublicKey == nil { | ||
return "" | ||
} | ||
|
||
return *q.QueuePublicKey | ||
} | ||
|
||
func (q *QueueRegistration) GetQueueAddress() string { | ||
// return zero value if Worker type or ID field is nil | ||
if q == nil || q.QueueAddress == nil { | ||
return "" | ||
} | ||
|
||
return *q.QueueAddress | ||
} | ||
|
||
// SetPublicKey sets the ID field. | ||
// | ||
// When the provided Worker type is nil, it | ||
// will set nothing and immediately return. | ||
func (q *QueueRegistration) SetPublicKey(v string) { | ||
// return if Worker type is nil | ||
if q == nil { | ||
return | ||
} | ||
|
||
q.QueuePublicKey = &v | ||
} | ||
|
||
// SetQueueAddress sets the ID field. | ||
// | ||
// When the provided Worker type is nil, it | ||
// will set nothing and immediately return. | ||
func (q *QueueRegistration) SetQueueAddress(v string) { | ||
// return if Worker type is nil | ||
if q == nil { | ||
return | ||
} | ||
|
||
q.QueueAddress = &v | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
// Copyright (c) 2023 Target Brands, Inc. All rights reserved. | ||
// | ||
// Use of this source code is governed by the LICENSE file in this repository. | ||
|
||
package library | ||
|
||
import ( | ||
"testing" | ||
) | ||
|
||
func TestLibrary_Queue_Registration_Getters(t *testing.T) { | ||
// setup tests | ||
tests := []struct { | ||
qR *QueueRegistration | ||
want *QueueRegistration | ||
}{ | ||
{ | ||
qR: testQueueRegistration(), | ||
want: testQueueRegistration(), | ||
}, | ||
{ | ||
qR: new(QueueRegistration), | ||
want: new(QueueRegistration), | ||
}, | ||
} | ||
|
||
// run tests | ||
for _, test := range tests { | ||
if test.qR.GetQueueAddress() != test.want.GetQueueAddress() { | ||
t.Errorf("GetQueueAddress is %v, want %v", test.qR.GetQueueAddress(), test.want.GetQueueAddress()) | ||
} | ||
|
||
if test.qR.GetPublicKey() != test.want.GetPublicKey() { | ||
t.Errorf("GetPublicKey is %v, want %v", test.qR.GetPublicKey(), test.want.GetPublicKey()) | ||
} | ||
|
||
Check failure on line 36 in library/queue_registration_test.go GitHub Actions / golangci[golangci] library/queue_registration_test.go#L36
Raw output
|
||
} | ||
Check failure on line 37 in library/queue_registration_test.go GitHub Actions / full-review
Check failure on line 37 in library/queue_registration_test.go GitHub Actions / diff-review
Check failure on line 37 in library/queue_registration_test.go GitHub Actions / diff-review
Check failure on line 37 in library/queue_registration_test.go GitHub Actions / golangci[golangci] library/queue_registration_test.go#L37
Raw output
|
||
} | ||
|
||
func TestLibrary_QueueRegistration_Setters(t *testing.T) { | ||
// setup types | ||
var w *QueueRegistration | ||
|
||
// setup tests | ||
tests := []struct { | ||
qR *QueueRegistration | ||
want *QueueRegistration | ||
}{ | ||
{ | ||
qR: testQueueRegistration(), | ||
want: testQueueRegistration(), | ||
}, | ||
{ | ||
qR: w, | ||
want: new(QueueRegistration), | ||
}, | ||
} | ||
|
||
// run tests | ||
for _, test := range tests { | ||
test.qR.SetQueueAddress(test.want.GetQueueAddress()) | ||
test.qR.SetPublicKey(test.want.GetPublicKey()) | ||
|
||
if test.qR.GetQueueAddress() != test.want.GetQueueAddress() { | ||
t.Errorf("GetQueueAddress is %v, want %v", test.qR.GetQueueAddress(), test.want.GetQueueAddress()) | ||
} | ||
|
||
if test.qR.GetPublicKey() != test.want.GetPublicKey() { | ||
t.Errorf("GetPublicKey is %v, want %v", test.qR.GetPublicKey(), test.want.GetPublicKey()) | ||
} | ||
} | ||
} | ||
|
||
// testWorker is a test helper function to create a Worker | ||
// type with all fields set to a fake value. | ||
func testQueueRegistration() *QueueRegistration { | ||
w := new(QueueRegistration) | ||
|
||
w.SetPublicKey("http://localhost:8080") | ||
w.SetPublicKey("worker_0") | ||
|
||
return w | ||
} |