From 02e31146cc744896fd8506cb4a0ef85aa0cf9b43 Mon Sep 17 00:00:00 2001 From: Mohammed Sohail Date: Sat, 14 Jan 2023 09:20:16 +0000 Subject: [PATCH] refactor: move filter and fetch to pkg --- .env.test.example | 1 - Makefile | 5 ++--- cmd/filters.go | 2 +- cmd/init.go | 2 +- cmd/main.go | 2 +- internal/pipeline/pipeline.go | 4 ++-- {internal => pkg}/fetch/fetch.go | 0 {internal => pkg}/fetch/graphql.go | 0 {internal => pkg}/fetch/graphql_test.go | 0 {internal => pkg}/filter/address_filter.go | 2 +- {internal => pkg}/filter/address_filter_test.go | 2 +- {internal => pkg}/filter/decode_filter.go | 2 +- {internal => pkg}/filter/decode_filter_test.go | 2 +- {internal => pkg}/filter/filter.go | 2 +- 14 files changed, 12 insertions(+), 14 deletions(-) delete mode 100644 .env.test.example rename {internal => pkg}/fetch/fetch.go (100%) rename {internal => pkg}/fetch/graphql.go (100%) rename {internal => pkg}/fetch/graphql_test.go (100%) rename {internal => pkg}/filter/address_filter.go (91%) rename {internal => pkg}/filter/address_filter_test.go (95%) rename {internal => pkg}/filter/decode_filter.go (96%) rename {internal => pkg}/filter/decode_filter_test.go (96%) rename {internal => pkg}/filter/filter.go (78%) diff --git a/.env.test.example b/.env.test.example deleted file mode 100644 index 0412928..0000000 --- a/.env.test.example +++ /dev/null @@ -1 +0,0 @@ -export TEST_GRAPHQL_ENDPOINT= \ No newline at end of file diff --git a/Makefile b/Makefile index 2ab9342..365da5f 100644 --- a/Makefile +++ b/Makefile @@ -13,6 +13,5 @@ mod: go mod tidy go mod verify -test: - source .env.test - go test -v -covermode atomic -coverprofile=covprofile ./internal/... \ No newline at end of file +test-pkg: + TEST_GRAPHQL_ENDPOINT=https://rpc.alfajores.celo.grassecon.net/graphql go test -v -covermode atomic -coverprofile=covprofile ./pkg/... \ No newline at end of file diff --git a/cmd/filters.go b/cmd/filters.go index 1fedbea..1439c2f 100644 --- a/cmd/filters.go +++ b/cmd/filters.go @@ -1,7 +1,7 @@ package main import ( - "github.com/grassrootseconomics/cic-chain-events/internal/filter" + "github.com/grassrootseconomics/cic-chain-events/pkg/filter" ) func initAddressFilter() filter.Filter { diff --git a/cmd/init.go b/cmd/init.go index 8096f2e..4f03cc7 100644 --- a/cmd/init.go +++ b/cmd/init.go @@ -5,9 +5,9 @@ import ( "strings" "github.com/alitto/pond" - "github.com/grassrootseconomics/cic-chain-events/internal/fetch" "github.com/grassrootseconomics/cic-chain-events/internal/pool" "github.com/grassrootseconomics/cic-chain-events/internal/store" + "github.com/grassrootseconomics/cic-chain-events/pkg/fetch" "github.com/jackc/pgx/v5" "github.com/knadh/goyesql/v2" "github.com/knadh/koanf" diff --git a/cmd/main.go b/cmd/main.go index e2b4db0..69f91e7 100644 --- a/cmd/main.go +++ b/cmd/main.go @@ -11,9 +11,9 @@ import ( "time" "github.com/grassrootseconomics/cic-chain-events/internal/api" - "github.com/grassrootseconomics/cic-chain-events/internal/filter" "github.com/grassrootseconomics/cic-chain-events/internal/pipeline" "github.com/grassrootseconomics/cic-chain-events/internal/syncer" + "github.com/grassrootseconomics/cic-chain-events/pkg/filter" "github.com/knadh/goyesql/v2" "github.com/knadh/koanf" "github.com/zerodha/logf" diff --git a/internal/pipeline/pipeline.go b/internal/pipeline/pipeline.go index da87149..b6f589c 100644 --- a/internal/pipeline/pipeline.go +++ b/internal/pipeline/pipeline.go @@ -3,9 +3,9 @@ package pipeline import ( "context" - "github.com/grassrootseconomics/cic-chain-events/internal/fetch" - "github.com/grassrootseconomics/cic-chain-events/internal/filter" "github.com/grassrootseconomics/cic-chain-events/internal/store" + "github.com/grassrootseconomics/cic-chain-events/pkg/fetch" + "github.com/grassrootseconomics/cic-chain-events/pkg/filter" "github.com/jackc/pgx/v5" "github.com/zerodha/logf" ) diff --git a/internal/fetch/fetch.go b/pkg/fetch/fetch.go similarity index 100% rename from internal/fetch/fetch.go rename to pkg/fetch/fetch.go diff --git a/internal/fetch/graphql.go b/pkg/fetch/graphql.go similarity index 100% rename from internal/fetch/graphql.go rename to pkg/fetch/graphql.go diff --git a/internal/fetch/graphql_test.go b/pkg/fetch/graphql_test.go similarity index 100% rename from internal/fetch/graphql_test.go rename to pkg/fetch/graphql_test.go diff --git a/internal/filter/address_filter.go b/pkg/filter/address_filter.go similarity index 91% rename from internal/filter/address_filter.go rename to pkg/filter/address_filter.go index 172d721..96ec2c3 100644 --- a/internal/filter/address_filter.go +++ b/pkg/filter/address_filter.go @@ -5,7 +5,7 @@ import ( "sync" celo "github.com/grassrootseconomics/cic-celo-sdk" - "github.com/grassrootseconomics/cic-chain-events/internal/fetch" + "github.com/grassrootseconomics/cic-chain-events/pkg/fetch" "github.com/zerodha/logf" ) diff --git a/internal/filter/address_filter_test.go b/pkg/filter/address_filter_test.go similarity index 95% rename from internal/filter/address_filter_test.go rename to pkg/filter/address_filter_test.go index e8273b1..772ce98 100644 --- a/internal/filter/address_filter_test.go +++ b/pkg/filter/address_filter_test.go @@ -5,7 +5,7 @@ import ( "sync" "testing" - "github.com/grassrootseconomics/cic-chain-events/internal/fetch" + "github.com/grassrootseconomics/cic-chain-events/pkg/fetch" "github.com/stretchr/testify/suite" "github.com/zerodha/logf" ) diff --git a/internal/filter/decode_filter.go b/pkg/filter/decode_filter.go similarity index 96% rename from internal/filter/decode_filter.go rename to pkg/filter/decode_filter.go index d96bafa..6d4f529 100644 --- a/internal/filter/decode_filter.go +++ b/pkg/filter/decode_filter.go @@ -5,7 +5,7 @@ import ( "math/big" "github.com/celo-org/celo-blockchain/common" - "github.com/grassrootseconomics/cic-chain-events/internal/fetch" + "github.com/grassrootseconomics/cic-chain-events/pkg/fetch" "github.com/grassrootseconomics/w3-celo-patch" "github.com/zerodha/logf" ) diff --git a/internal/filter/decode_filter_test.go b/pkg/filter/decode_filter_test.go similarity index 96% rename from internal/filter/decode_filter_test.go rename to pkg/filter/decode_filter_test.go index c7f48ba..f801487 100644 --- a/internal/filter/decode_filter_test.go +++ b/pkg/filter/decode_filter_test.go @@ -4,7 +4,7 @@ import ( "context" "testing" - "github.com/grassrootseconomics/cic-chain-events/internal/fetch" + "github.com/grassrootseconomics/cic-chain-events/pkg/fetch" "github.com/stretchr/testify/suite" "github.com/zerodha/logf" ) diff --git a/internal/filter/filter.go b/pkg/filter/filter.go similarity index 78% rename from internal/filter/filter.go rename to pkg/filter/filter.go index bf9ed2a..4006a94 100644 --- a/internal/filter/filter.go +++ b/pkg/filter/filter.go @@ -3,7 +3,7 @@ package filter import ( "context" - "github.com/grassrootseconomics/cic-chain-events/internal/fetch" + "github.com/grassrootseconomics/cic-chain-events/pkg/fetch" ) // Filter defines a read only filter which must return next as true/false or an error