Skip to content

Commit

Permalink
[IMRPOVEMENT] move provider package to app
Browse files Browse the repository at this point in the history
  • Loading branch information
bardia-heydari committed Sep 2, 2019
1 parent 4a211dd commit d02b675
Show file tree
Hide file tree
Showing 14 changed files with 18 additions and 19 deletions.
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ PACKAGES := $(shell go list ./... | grep -v /vendor)
PROTOS = $(patsubst ./%,%,$(shell find . -name "*.proto"))
PBS = $(patsubst %.proto,%.pb.go,$(patsubst api%,pkg%,$(PROTOS)))
MOCK_PACKAGES = \
internal/pkg/provider \
internal/app/provider \
internal/pkg/metrics

MOCKED_FILES = $(shell find . -name DOES_NOT_EXIST_FILE $(patsubst %,-or -path "./%/mocks/*.go",$(MOCK_PACKAGES)))
Expand All @@ -25,7 +25,7 @@ clean: ## to remove generated files
-rm -rf postviewd
-find . -type d -name mocks -exec rm -rf \{} +

postviewd: $(SRCS) $(PBS) ## Compile postview daemon
postviewd: $(SRCS) $(PBS) | generate ## Compile postview daemon
go build -o $@ -ldflags="$(LD_FLAGS)" ./cmd/$@

docker: ## to build docker image
Expand Down
2 changes: 1 addition & 1 deletion cmd/postviewd/container.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"context"
"github.com/cafebazaar/go-boilerplate/internal/app/core"
"github.com/cafebazaar/go-boilerplate/internal/pkg/grpcserver"
"github.com/cafebazaar/go-boilerplate/internal/pkg/provider"
"github.com/cafebazaar/go-boilerplate/internal/app/provider"
"github.com/google/wire"
"github.com/spf13/cobra"
)
Expand Down
6 changes: 3 additions & 3 deletions cmd/postviewd/serve.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,27 +3,27 @@ package main
import (
"context"
"fmt"
"github.com/cafebazaar/go-boilerplate/internal/app/provider"
"github.com/cafebazaar/go-boilerplate/internal/pkg/grpcserver"
"github.com/cafebazaar/go-boilerplate/internal/pkg/metrics/prometheus"
"github.com/cafebazaar/go-boilerplate/pkg/postview"
"log"
"os"
"os/signal"
"sync"
"syscall"

"github.com/allegro/bigcache"
"github.com/cafebazaar/go-boilerplate/pkg/cache"
"github.com/cafebazaar/go-boilerplate/pkg/cache/adaptors"
"github.com/cafebazaar/go-boilerplate/pkg/cache/middlewares"
"github.com/cafebazaar/go-boilerplate/pkg/cache/multilayercache"
"github.com/cafebazaar/go-boilerplate/pkg/errors"
"github.com/allegro/bigcache"
"github.com/cafebazaar/go-boilerplate/pkg/postview"

"github.com/go-redis/redis"
"github.com/sirupsen/logrus"
"github.com/spf13/cobra"

"github.com/cafebazaar/go-boilerplate/internal/pkg/provider"
"github.com/cafebazaar/go-boilerplate/pkg/sql"
)

Expand Down
2 changes: 1 addition & 1 deletion internal/app/core/core.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"github.com/cafebazaar/go-boilerplate/pkg/errors"
"golang.org/x/xerrors"

"github.com/cafebazaar/go-boilerplate/internal/pkg/provider"
"github.com/cafebazaar/go-boilerplate/internal/app/provider"
"github.com/cafebazaar/go-boilerplate/pkg/cache"
"github.com/cafebazaar/go-boilerplate/pkg/postview"
"github.com/golang/protobuf/proto"
Expand Down
4 changes: 2 additions & 2 deletions internal/app/core/core_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package core_test

import (
"context"
"github.com/cafebazaar/go-boilerplate/internal/pkg/provider"
"github.com/cafebazaar/go-boilerplate/internal/app/provider"
"github.com/cafebazaar/go-boilerplate/pkg/cache/adaptors"
"github.com/sirupsen/logrus"
"github.com/stretchr/testify/mock"
Expand All @@ -14,7 +14,7 @@ import (
"github.com/cafebazaar/go-boilerplate/pkg/postview"
"github.com/golang/protobuf/proto"

providerMocks "github.com/cafebazaar/go-boilerplate/internal/pkg/provider/mocks"
providerMocks "github.com/cafebazaar/go-boilerplate/internal/app/provider/mocks"
"github.com/stretchr/testify/suite"
)

Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
package provider_test

import (
context "context"
"context"
"errors"
"github.com/cafebazaar/go-boilerplate/internal/app/provider"
"testing"

providerMocks "github.com/cafebazaar/go-boilerplate/internal/app/provider/mocks"
metricsMocks "github.com/cafebazaar/go-boilerplate/internal/pkg/metrics/mocks"
"github.com/cafebazaar/go-boilerplate/internal/pkg/provider"
providerMocks "github.com/cafebazaar/go-boilerplate/internal/pkg/provider/mocks"

"github.com/stretchr/testify/mock"
"github.com/stretchr/testify/suite"
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"context"
"testing"

"github.com/cafebazaar/go-boilerplate/internal/pkg/provider"
"github.com/cafebazaar/go-boilerplate/pkg/postview"
"github.com/stretchr/testify/suite"
"golang.org/x/xerrors"
Expand All @@ -13,7 +12,7 @@ import (
type MemoryProviderTestSuite struct {
suite.Suite

provider provider.PostProvider
provider PostProvider
}

func TestMemoryProviderTestSuite(t *testing.T) {
Expand All @@ -22,7 +21,7 @@ func TestMemoryProviderTestSuite(t *testing.T) {

func (s *MemoryProviderTestSuite) TestShouldReturnNotFoundInitially() {
_, err := s.provider.GetPost(context.Background(), "token")
s.True(xerrors.Is(err, provider.ErrNotFound))
s.True(xerrors.Is(err, ErrNotFound))
}

func (s *MemoryProviderTestSuite) TestShouldReturnPostAfterAdd() {
Expand All @@ -46,5 +45,5 @@ func (s *MemoryProviderTestSuite) TestShouldReturnPostAfterAdd() {
}

func (s *MemoryProviderTestSuite) SetupTest() {
s.provider = provider.NewMemory()
s.provider = NewMemory()
}
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"github.com/golang/protobuf/proto"

"github.com/cafebazaar/go-boilerplate/pkg/postview"
gormigrate "gopkg.in/gormigrate.v1"
"gopkg.in/gormigrate.v1"

"github.com/jinzhu/gorm"
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ package provider_test

import (
"context"
"github.com/cafebazaar/go-boilerplate/internal/app/provider"
"io"
"testing"

"github.com/cafebazaar/go-boilerplate/internal/pkg/provider"
"github.com/cafebazaar/go-boilerplate/pkg/postview"
"github.com/cafebazaar/go-boilerplate/pkg/sql"
"github.com/stretchr/testify/suite"
Expand Down
2 changes: 1 addition & 1 deletion pkg/cache/adaptors/bigcache.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ package adaptors

import (
"context"
"github.com/cafebazaar/go-boilerplate/pkg/cache"
"github.com/allegro/bigcache"
"github.com/cafebazaar/go-boilerplate/pkg/cache"
"github.com/pkg/errors"
)

Expand Down

0 comments on commit d02b675

Please sign in to comment.