Skip to content

Commit

Permalink
fix(temp registry): make configuration not interrupt common config
Browse files Browse the repository at this point in the history
  • Loading branch information
b5 committed Feb 3, 2020
1 parent 19f12bd commit b618472
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 2 deletions.
15 changes: 14 additions & 1 deletion registry/regserver/handlers/handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"time"

"github.com/qri-io/apiutil"
"github.com/qri-io/dataset"
"github.com/qri-io/qri/base"
"github.com/qri-io/qri/registry"
"github.com/qri-io/qri/repo"
Expand Down Expand Up @@ -95,8 +96,20 @@ func HealthCheckHandler(w http.ResponseWriter, r *http.Request) {

// HomeFeedHandler provides access to the home feed
func HomeFeedHandler(r repo.Repo) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
return func(w http.ResponseWriter, req *http.Request) {
refs, err := base.ListDatasets(req.Context(), r, "", 30, 0, false, true, false)
if err != nil {
apiutil.WriteErrResponse(w, http.StatusBadRequest, err)
return
}
res := make([]*dataset.Dataset, len(refs))
for i, ref := range refs {
ref.Dataset.Name = ref.Name
ref.Dataset.Peername = ref.Peername
res[i] = ref.Dataset
}

apiutil.WriteResponse(w, res)
}
}

Expand Down
10 changes: 9 additions & 1 deletion registry/temp_registry_server/temp.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ func NewTempRepoRegistry(ctx context.Context) (*lib.Instance, registry.Registry,
}
cleanup := mock.Delete

cfg := mock.GetConfig()
cfg := conf(mock)
cfg.Registry.Location = ""
cfg.Remote = &config.Remote{
Enabled: true,
Expand Down Expand Up @@ -58,6 +58,14 @@ func NewTempRepoRegistry(ctx context.Context) (*lib.Instance, registry.Registry,
return inst, reg, cleanup, nil
}

func conf(mock repotest.TempRepo) *config.Config {
cfg := mock.GetConfig()
cfg.API.Port = 99999
cfg.Webapp.Enabled = false
cfg.RPC.Enabled = false
return cfg
}

func addBasicDataset(inst *lib.Instance) {
dsm := lib.NewDatasetRequestsInstance(inst)
res := reporef.DatasetRef{}
Expand Down

0 comments on commit b618472

Please sign in to comment.