forked from flyteorg/flyte
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request flyteorg#79 from lyft/fairness-hard-cap
Fix token format and add unit tests
- Loading branch information
Showing
2 changed files
with
56 additions
and
1 deletion.
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
55 changes: 55 additions & 0 deletions
55
pkg/controller/nodes/task/resourcemanager/resourcemanager_test.go
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,55 @@ | ||
package resourcemanager | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/lyft/flyteidl/gen/pb-go/flyteidl/core" | ||
) | ||
|
||
func TestComposeTokenPrefix(t *testing.T) { | ||
type args struct { | ||
id *core.TaskExecutionIdentifier | ||
} | ||
tests := []struct { | ||
name string | ||
args args | ||
want TokenPrefix | ||
}{ | ||
{name: "composing the prefix from task execution id", | ||
args: args{id: &core.TaskExecutionIdentifier{ | ||
TaskId: nil, | ||
NodeExecutionId: &core.NodeExecutionIdentifier{ExecutionId: &core.WorkflowExecutionIdentifier{Project: "testproject", Domain: "testdomain", Name: "testname"}}, | ||
}}, | ||
want: TokenPrefix("ex:testproject:testdomain:testname"), | ||
}, | ||
} | ||
for _, tt := range tests { | ||
t.Run(tt.name, func(t *testing.T) { | ||
if got := ComposeTokenPrefix(tt.args.id); got != tt.want { | ||
t.Errorf("ComposeTokenPrefix() = %v, want %v", got, tt.want) | ||
} | ||
}) | ||
} | ||
} | ||
|
||
func TestToken_prepend(t *testing.T) { | ||
type args struct { | ||
prefix TokenPrefix | ||
} | ||
tests := []struct { | ||
name string | ||
t Token | ||
args args | ||
want Token | ||
}{ | ||
{name: "Prepend should prepend", t: Token("abcdefg-hijklmn"), args: args{prefix: TokenPrefix("tok:prefix")}, | ||
want: Token("tok:prefix-abcdefg-hijklmn")}, | ||
} | ||
for _, tt := range tests { | ||
t.Run(tt.name, func(t *testing.T) { | ||
if got := tt.t.prepend(tt.args.prefix); got != tt.want { | ||
t.Errorf("prepend() = %v, want %v", got, tt.want) | ||
} | ||
}) | ||
} | ||
} |