mirror of
https://github.com/drone-plugins/drone-npm.git
synced 2026-06-04 18:23:52 +08:00
46 lines
1.3 KiB
Go
46 lines
1.3 KiB
Go
package main
|
|
|
|
import (
|
|
"testing"
|
|
)
|
|
|
|
func TestTokenRCContents(t *testing.T) {
|
|
conf := Config{
|
|
Registry: "https://npm.someorg.com/",
|
|
Token: "token",
|
|
}
|
|
actual := npmrcContentsToken(conf)
|
|
expected := "//npm.someorg.com/:_authToken=token"
|
|
if actual != expected {
|
|
t.Errorf("Unexpected token config (Got: %s, Expected: %s)", actual, expected)
|
|
}
|
|
|
|
conf.Registry = "https://npm.someorg.com/with/path/"
|
|
actual = npmrcContentsToken(conf)
|
|
expected = "//npm.someorg.com/with/path/:_authToken=token"
|
|
if actual != expected {
|
|
t.Errorf("Unexpected token config (Got: %s, Expected: %s)", actual, expected)
|
|
}
|
|
|
|
conf.Registry = GlobalRegistry
|
|
actual = npmrcContentsToken(conf)
|
|
expected = "//registry.npmjs.org/:_authToken=token"
|
|
if actual != expected {
|
|
t.Errorf("Unexpected token config (Got: %s, Expected: %s)", actual, expected)
|
|
}
|
|
|
|
conf.Registry = "https://npm.someorg.com"
|
|
actual = npmrcContentsToken(conf)
|
|
expected = "//npm.someorg.com/:_authToken=token"
|
|
if actual != expected {
|
|
t.Errorf("Unexpected token config (Got: %s, Expected: %s)", actual, expected)
|
|
}
|
|
|
|
conf.Registry = "https://npm.someorg.com/with/path"
|
|
actual = npmrcContentsToken(conf)
|
|
expected = "//npm.someorg.com/with/path/:_authToken=token"
|
|
if actual != expected {
|
|
t.Errorf("Unexpected token config (Got: %s, Expected: %s)", actual, expected)
|
|
}
|
|
}
|