Skip to content

Commit

Permalink
Merge branch 'master' into sync-fill
Browse files Browse the repository at this point in the history
  • Loading branch information
arschles authored Jul 19, 2018
2 parents 5e515e2 + d74e064 commit 2176005
Show file tree
Hide file tree
Showing 17 changed files with 35 additions and 462 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,5 +80,5 @@ The Athens project would not be possible without the amazing projects it builds
This project follows the [Contributor Covenant](https://www.contributor-covenant.org/) (English version [here](https://www.contributor-covenant.org/version/1/4/code-of-conduct)) code of conduct.

If you have concerns, notice a code of conduct violation, or otherwise would like to talk about something
related to this code of conduct, please reach out to me, Aaron Schlesinger on the [Gophers Slack](https://gophers.slack.com/. My username is `arschles`. Note that in the future, we will be expanding the
related to this code of conduct, please reach out to me, Aaron Schlesinger on the [Gophers Slack](https://gophers.slack.com/). My username is `arschles`. Note that in the future, we will be expanding the
ways that you can contact us regarding the code of conduct.
2 changes: 0 additions & 2 deletions cmd/proxy/actions/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ import (
"github.com/gomods/athens/pkg/log"
"github.com/gomods/athens/pkg/module"
"github.com/gomods/athens/pkg/storage"
"github.com/gomods/athens/pkg/user"
"github.com/gomodule/redigo/redis"
"github.com/rs/cors"
"github.com/unrolled/secure"
Expand All @@ -43,7 +42,6 @@ var app *buffalo.App
var T *i18n.Translator

var gopath string
var userStore *user.Store

func init() {
g, err := env.GoPath()
Expand Down
25 changes: 0 additions & 25 deletions cmd/proxy/actions/auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (
"os"

"github.com/gobuffalo/buffalo"
"github.com/gomods/athens/pkg/user"
"github.com/markbates/goth"
"github.com/markbates/goth/gothic"
"github.com/markbates/goth/providers/github"
Expand All @@ -18,27 +17,3 @@ func initializeAuth(app *buffalo.App) {
github.New(os.Getenv("GITHUB_KEY"), os.Getenv("GITHUB_SECRET"), fmt.Sprintf("%s%s", app.Host, "/auth/github/callback")),
)
}

func authCallback(store user.Store) func(c buffalo.Context) error {
return func(c buffalo.Context) error {
usr, err := gothic.CompleteUserAuth(c.Response(), c.Request())
if err != nil {
return c.Render(401, proxy.JSON(err.Error()))
}
// Do something with the user, maybe register them/sign them in
var u *user.User
u, err = store.Get(usr.UserID, usr.Provider)
if err != nil {
if err == user.ErrNotFound {
// insert the user
u = user.FromGothic(&usr)
e := store.Save(u)
if e != nil {
return c.Render(500, proxy.JSON(e.Error()))
}
}
return c.Render(500, proxy.JSON(err.Error()))
}
return c.Render(200, proxy.JSON(u))
}
}
10 changes: 0 additions & 10 deletions cmd/proxy/actions/cdn.go

This file was deleted.

5 changes: 0 additions & 5 deletions pkg/module/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,6 @@ const (
gitIgnoreFilename = ".gitignore"
)

type file struct {
Name string
Body string
}

// MakeZip takes dir and module info and generates vgo valid zip
// the dir must end with a "/"
func MakeZip(fs afero.Fs, dir, module, version string) *io.PipeReader {
Expand Down
1 change: 0 additions & 1 deletion pkg/repo/github/github.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ import (

const (
fetchRepoURI string = "https://api.github.com/repos/%s/%s/tarball/%s"
tmpFileName = "%s-%s-%s" // owner-repo-ref
)

type gitFetcher struct {
Expand Down
13 changes: 0 additions & 13 deletions pkg/storage/fs/all_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,6 @@ const (
version = "v1.0.0"
)

var (
// TODO: put these values inside of the suite, and generate longer values.
// This should help catch edge cases, like https://github.com/gomods/athens/issues/38
//
// Also, consider doing something similar to what testing/quick does
// with the Generator interface (https://godoc.org/testing/quick#Generator).
// The rough, simplified idea would be to run a single test case multiple
// times over different (increasing) values.
mod = []byte("123")
zip = []byte("456")
info = []byte("789")
)

type FsTests struct {
suite.Suite
storage storage.Backend
Expand Down
42 changes: 0 additions & 42 deletions pkg/storage/fs/deleter_test.go

This file was deleted.

50 changes: 0 additions & 50 deletions pkg/storage/minio/deleter_test.go

This file was deleted.

18 changes: 0 additions & 18 deletions pkg/storage/mongo/all_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,24 +7,6 @@ import (
"github.com/stretchr/testify/suite"
)

const (
module = "testmodule"
version = "v1.0.0"
)

var (
// TODO: put these values inside of the suite, and generate longer values.
// This should help catch edge cases, like https://github.com/gomods/athens/issues/38
//
// Also, consider doing something similar to what testing/quick does
// with the Generator interface (https://godoc.org/testing/quick#Generator).
// The rough, simplified idea would be to run a single test case multiple
// times over different (increasing) values.
mod = []byte("123")
zip = []byte("456")
info = []byte("789")
)

type MongoTests struct {
suite.Suite
storage storage.BackendConnector
Expand Down
42 changes: 0 additions & 42 deletions pkg/storage/mongo/deleter_test.go

This file was deleted.

18 changes: 0 additions & 18 deletions pkg/storage/rdbms/all_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,24 +7,6 @@ import (
"github.com/gomods/athens/pkg/storage"
)

const (
module = "testmodule"
version = "v1.0.0"
)

var (
// TODO: put these values inside of the suite, and generate longer values.
// This should help catch edge cases, like https://github.com/gomods/athens/issues/38
//
// Also, consider doing something similar to what testing/quick does
// with the Generator interface (https://godoc.org/testing/quick#Generator).
// The rough, simplified idea would be to run a single test case multiple
// times over different (increasing) values.
mod = []byte("123")
zip = []byte("456")
info = []byte("789")
)

type RDBMSTestSuite struct {
*suite.Model
storage storage.BackendConnector
Expand Down
42 changes: 0 additions & 42 deletions pkg/storage/rdbms/deleter_test.go

This file was deleted.

34 changes: 34 additions & 0 deletions pkg/storage/storage_tests/module_storage/storage_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
"context"
"io/ioutil"
"testing"
"time"

"github.com/gobuffalo/suite"
"github.com/gomods/athens/pkg/storage"
Expand Down Expand Up @@ -77,6 +78,7 @@ func (d *TestSuites) TestStorages() {
d.testNotFound(store)
d.testGetSaveListRoundTrip(store)
d.testList(store)
d.testDelete(store)

// TODO: more tests to come

Expand Down Expand Up @@ -122,3 +124,35 @@ func (d *TestSuites) testGetSaveListRoundTrip(ts storage.TestSuite) {
r.Equal(d.zip, zipContent, hrn)
r.Equal(d.info, gotten.Info, hrn)
}

func (d *TestSuites) testDelete(ts storage.TestSuite) {
r := d.Require()
version := "delete" + time.Now().String()
err := ts.Storage().Save(context.Background(), d.module, version, d.mod, bytes.NewReader(d.zip), d.info)
r.NoError(err)

tests := []struct {
module string
version string
want error
}{
{
module: "does/not/exist",
version: "v1.0.0",
want: storage.ErrVersionNotFound{
Module: "does/not/exist",
Version: "v1.0.0",
},
},
{
module: d.module,
version: version,
},
}
for _, test := range tests {
err := ts.Storage().Delete(test.module, test.version)
r.Equal(test.want, err)
exists := ts.Storage().Exists(test.module, test.version)
r.Equal(false, exists)
}
}
Loading

0 comments on commit 2176005

Please sign in to comment.