-
Notifications
You must be signed in to change notification settings - Fork 103
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
a226fbc
commit 0cdd0e9
Showing
2 changed files
with
50 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
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,49 @@ | ||
//go:build windows | ||
// +build windows | ||
|
||
package launcher | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/stretchr/testify/require" | ||
) | ||
|
||
func Test_ServiceName(t *testing.T) { | ||
t.Parallel() | ||
|
||
for _, tt := range []struct { | ||
testCaseName string | ||
identifier string | ||
expectedServiceName string | ||
}{ | ||
{ | ||
testCaseName: "empty identifier expecting default service name", | ||
identifier: " ", | ||
expectedServiceName: "LauncherKolideK2Svc", | ||
}, | ||
{ | ||
testCaseName: "default identifier expecting default service name", | ||
identifier: "kolide-k2", | ||
expectedServiceName: "LauncherKolideK2Svc", | ||
}, | ||
{ | ||
testCaseName: "preprod identifier expecting preprod service name", | ||
identifier: "kolide-preprod-k2", | ||
expectedServiceName: "LauncherKolidePreprodK2Svc", | ||
}, | ||
{ | ||
testCaseName: "mangled identifier expecting default service name", | ||
identifier: "kolide-!@_k2", | ||
expectedServiceName: "LauncherKolideK2Svc", | ||
}, | ||
} { | ||
tt := tt | ||
t.Run(tt.testCaseName, func(t *testing.T) { | ||
t.Parallel() | ||
|
||
serviceName := ServiceName(tt.identifier) | ||
require.Equal(t, tt.expectedServiceName, serviceName, "expected sanitized service name value to match") | ||
}) | ||
} | ||
} |