rio/internal/repo/repo_test.go

40 lines
863 B
Go

package repo
import (
"net/http"
"testing"
"time"
"code.gitea.io/sdk/gitea"
)
var (
giteaClient, _ = gitea.NewClient(
"https://git.polynom.me",
gitea.SetHTTPClient(&http.Client{Timeout: 10 * time.Second}),
gitea.SetToken(""),
gitea.SetUserAgent("rio/testing"),
)
)
func TestCanRequestCertificatePositiveUser(t *testing.T) {
res := CanRequestCertificate("papatutuwawa", giteaClient)
if !res {
t.Fatalf("User papatutuwawa should be servable")
}
}
func TestCanRequestCertificatePositiveOrganisation(t *testing.T) {
res := CanRequestCertificate("moxxy", giteaClient)
if !res {
t.Fatalf("Organisation moxxy should be servable")
}
}
func TestCanRequestCertificateNegative(t *testing.T) {
res := CanRequestCertificate("user-who-does-not-exist", giteaClient)
if res {
t.Fatalf("User user-who-does-not-exist should not be servable")
}
}