Skip to content

Commit

Permalink
Rename namespace-registry to conform to go standards and move registr…
Browse files Browse the repository at this point in the history
…y db test

This renames a few things to better conform to go conventions, and it moves the test
Joe put together for testing the client commands closer to the source.
  • Loading branch information
jhiemstrawisc committed Nov 29, 2023
1 parent efb537c commit c73a144
Show file tree
Hide file tree
Showing 9 changed files with 14 additions and 15 deletions.
2 changes: 1 addition & 1 deletion cmd/cache_serve.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ import (
"github.com/pelicanplatform/pelican/daemon"
"github.com/pelicanplatform/pelican/director"
"github.com/pelicanplatform/pelican/metrics"
nsregistry "github.com/pelicanplatform/pelican/namespace-registry"
nsregistry "github.com/pelicanplatform/pelican/namespace_registry"
"github.com/pelicanplatform/pelican/param"
"github.com/pelicanplatform/pelican/utils"
"github.com/pelicanplatform/pelican/xrootd"
Expand Down
2 changes: 1 addition & 1 deletion cmd/namespace_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import (

"github.com/lestrrat-go/jwx/v2/jwk"
"github.com/pelicanplatform/pelican/config"
nsregistry "github.com/pelicanplatform/pelican/namespace-registry"
nsregistry "github.com/pelicanplatform/pelican/namespace_registry"
"github.com/pelicanplatform/pelican/param"
"github.com/pkg/errors"
log "github.com/sirupsen/logrus"
Expand Down
2 changes: 1 addition & 1 deletion cmd/namespace_registry_serve.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import (

"github.com/pkg/errors"

nsregistry "github.com/pelicanplatform/pelican/namespace-registry"
nsregistry "github.com/pelicanplatform/pelican/namespace_registry"
"github.com/pelicanplatform/pelican/web_ui"
log "github.com/sirupsen/logrus"
"github.com/spf13/cobra"
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
*
***************************************************************/

package main
package nsregistry

import (
"net/http/httptest"
Expand All @@ -26,7 +26,6 @@ import (

"github.com/gin-gonic/gin"
"github.com/pelicanplatform/pelican/config"
nsregistry "github.com/pelicanplatform/pelican/namespace-registry"
"github.com/spf13/viper"

"github.com/stretchr/testify/assert"
Expand All @@ -44,9 +43,9 @@ func TestServeNamespaceRegistry(t *testing.T) {
err := config.InitServer()
require.NoError(t, err)

err = nsregistry.InitializeDB()
err = InitializeDB()
require.NoError(t, err)
defer nsregistry.ShutdownDB()
defer ShutdownDB()

gin.SetMode(gin.TestMode)
engine := gin.Default()
Expand All @@ -57,7 +56,7 @@ func TestServeNamespaceRegistry(t *testing.T) {
require.NoError(t, err)

//Configure registry
nsregistry.RegisterNamespaceRegistry(engine.Group("/"))
RegisterNamespaceRegistry(engine.Group("/"))

//Set up a server to use for testing
svr := httptest.NewServer(engine)
Expand All @@ -68,7 +67,7 @@ func TestServeNamespaceRegistry(t *testing.T) {
viper.Set("Origin.NamespacePrefix", "/test")

//Test functionality of registering a namespace (without identity)
err = nsregistry.NamespaceRegister(privKey, svr.URL+"/api/v1.0/registry", "", "/test")
err = NamespaceRegister(privKey, svr.URL+"/api/v1.0/registry", "", "/test")
require.NoError(t, err)

//Test we can list the namespace without an error
Expand All @@ -80,7 +79,7 @@ func TestServeNamespaceRegistry(t *testing.T) {
os.Stdout = w

//List the namespaces
err = nsregistry.NamespaceList(svr.URL + "/api/v1.0/registry")
err = NamespaceList(svr.URL + "/api/v1.0/registry")
require.NoError(t, err)
w.Close()
os.Stdout = oldStdout
Expand All @@ -99,7 +98,7 @@ func TestServeNamespaceRegistry(t *testing.T) {
r, w, _ := os.Pipe()
os.Stdout = w

err = nsregistry.NamespaceGet(svr.URL + "/api/v1.0/registry")
err = NamespaceGet(svr.URL + "/api/v1.0/registry")
require.NoError(t, err)
w.Close()
os.Stdout = oldStdout
Expand All @@ -112,13 +111,13 @@ func TestServeNamespaceRegistry(t *testing.T) {

t.Run("Test namespace delete", func(t *testing.T) {
//Test functionality of namespace delete
err = nsregistry.NamespaceDelete(svr.URL+"/api/v1.0/registry/test", "/test")
err = NamespaceDelete(svr.URL+"/api/v1.0/registry/test", "/test")
require.NoError(t, err)
var stdoutCapture string
oldStdout := os.Stdout
r, w, _ := os.Pipe()
os.Stdout = w
err = nsregistry.NamespaceGet(svr.URL + "/api/v1.0/registry")
err = NamespaceGet(svr.URL + "/api/v1.0/registry")
require.NoError(t, err)
w.Close()
os.Stdout = oldStdout
Expand Down
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion origin_ui/register_origin.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import (
"github.com/lestrrat-go/jwx/v2/jwk"
"github.com/pelicanplatform/pelican/config"
"github.com/pelicanplatform/pelican/metrics"
nsregistry "github.com/pelicanplatform/pelican/namespace-registry"
nsregistry "github.com/pelicanplatform/pelican/namespace_registry"
"github.com/pelicanplatform/pelican/param"
"github.com/pkg/errors"
log "github.com/sirupsen/logrus"
Expand Down
2 changes: 1 addition & 1 deletion origin_ui/register_origin_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ import (
"github.com/gin-gonic/gin"
"github.com/lestrrat-go/jwx/v2/jwk"
"github.com/pelicanplatform/pelican/config"
nsregistry "github.com/pelicanplatform/pelican/namespace-registry"
nsregistry "github.com/pelicanplatform/pelican/namespace_registry"
"github.com/spf13/viper"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
Expand Down

0 comments on commit c73a144

Please sign in to comment.