Nest packages under pkg

This commit is contained in:
Eric Meyer 2017-11-06 12:53:43 -06:00
parent cf5f2f28db
commit f4a603efcb
36 changed files with 45 additions and 54 deletions

2
.gitignore vendored
View File

@ -2,4 +2,4 @@
Gododir/godobin-* Gododir/godobin-*
test_data_dir/ test_data_dir/
vendor/ vendor/
config/environments/*.toml pkg/config/environments/*.toml

View File

@ -8,6 +8,6 @@ before_script:
- createdb vulcanize_private - createdb vulcanize_private
- psql vulcanize_private < migrations/schema.sql - psql vulcanize_private < migrations/schema.sql
script: script:
- go test -v ./blockchain_listener ./core ./geth ./observers - go test -v ./pkg/...
notifications: notifications:
email: false email: false

View File

@ -5,7 +5,7 @@ import (
"fmt" "fmt"
"github.com/8thlight/vulcanizedb/config" "github.com/8thlight/vulcanizedb/pkg/config"
do "gopkg.in/godo.v2" do "gopkg.in/godo.v2"
) )

View File

@ -71,7 +71,7 @@ The default location for Ethereum is:
You can create configuration files for additional environments. You can create configuration files for additional environments.
* Among other things, it will require the IPC file path * Among other things, it will require the IPC file path
* See `config/environments/private.toml` for an example * See `pkg/config/environments/private.toml` for an example
* You will need to do this if you want to run a node connecting to the public blockchain * You will need to do this if you want to run a node connecting to the public blockchain
## Running the Tests ## Running the Tests
@ -81,8 +81,8 @@ You can create configuration files for additional environments.
In order to run the integration tests, you will need to run them against a real blockchain. In order to run the integration tests, you will need to run them against a real blockchain.
1. Run `./scripts/start_private_blockchain` as a separate process. 1. Run `./scripts/start_private_blockchain` as a separate process.
2. `go test ./...` 2. `go test ./...` to run all tests.
### Unit Tests ### Unit Tests
1. `go test ./core` 1. `go test ./pkg/...`

View File

@ -6,12 +6,12 @@ import (
"flag" "flag"
"github.com/8thlight/vulcanizedb/blockchain_listener" "github.com/8thlight/vulcanizedb/pkg/blockchain_listener"
"github.com/8thlight/vulcanizedb/config" "github.com/8thlight/vulcanizedb/pkg/config"
"github.com/8thlight/vulcanizedb/core" "github.com/8thlight/vulcanizedb/pkg/core"
"github.com/8thlight/vulcanizedb/geth" "github.com/8thlight/vulcanizedb/pkg/geth"
"github.com/8thlight/vulcanizedb/observers" "github.com/8thlight/vulcanizedb/pkg/observers"
"github.com/8thlight/vulcanizedb/repositories" "github.com/8thlight/vulcanizedb/pkg/repositories"
"github.com/jmoiron/sqlx" "github.com/jmoiron/sqlx"
) )

View File

@ -1,25 +1,15 @@
package integration_test package integration_test
import ( import (
"path" "github.com/8thlight/vulcanizedb/pkg/blockchain_listener"
"runtime" "github.com/8thlight/vulcanizedb/pkg/config"
"github.com/8thlight/vulcanizedb/pkg/core"
"github.com/8thlight/vulcanizedb/blockchain_listener" "github.com/8thlight/vulcanizedb/pkg/fakes"
"github.com/8thlight/vulcanizedb/core" "github.com/8thlight/vulcanizedb/pkg/geth"
"github.com/8thlight/vulcanizedb/fakes"
"github.com/8thlight/vulcanizedb/geth"
. "github.com/onsi/ginkgo" . "github.com/onsi/ginkgo"
. "github.com/onsi/gomega" . "github.com/onsi/gomega"
) )
var (
_, filename, _, _ = runtime.Caller(0)
)
func RunTimePath() string {
return path.Join(path.Dir(filename), "../")
}
var _ = Describe("Reading from the Geth blockchain", func() { var _ = Describe("Reading from the Geth blockchain", func() {
var listener blockchain_listener.BlockchainListener var listener blockchain_listener.BlockchainListener
@ -27,7 +17,8 @@ var _ = Describe("Reading from the Geth blockchain", func() {
BeforeEach(func() { BeforeEach(func() {
observer = fakes.NewFakeBlockchainObserver() observer = fakes.NewFakeBlockchainObserver()
blockchain := geth.NewGethBlockchain(RunTimePath() + "/test_data_dir/geth.ipc") cfg := config.NewConfig("private")
blockchain := geth.NewGethBlockchain(cfg.Client.IPCPath)
observers := []core.BlockchainObserver{observer} observers := []core.BlockchainObserver{observer}
listener = blockchain_listener.NewBlockchainListener(blockchain, observers) listener = blockchain_listener.NewBlockchainListener(blockchain, observers)
}) })

View File

@ -1,6 +1,6 @@
package blockchain_listener package blockchain_listener
import "github.com/8thlight/vulcanizedb/core" import "github.com/8thlight/vulcanizedb/pkg/core"
type BlockchainListener struct { type BlockchainListener struct {
inputBlocks chan core.Block inputBlocks chan core.Block

View File

@ -1,9 +1,9 @@
package blockchain_listener_test package blockchain_listener_test
import ( import (
"github.com/8thlight/vulcanizedb/blockchain_listener" "github.com/8thlight/vulcanizedb/pkg/blockchain_listener"
"github.com/8thlight/vulcanizedb/core" "github.com/8thlight/vulcanizedb/pkg/core"
"github.com/8thlight/vulcanizedb/fakes" "github.com/8thlight/vulcanizedb/pkg/fakes"
. "github.com/onsi/ginkgo" . "github.com/onsi/ginkgo"
. "github.com/onsi/gomega" . "github.com/onsi/gomega"
) )

View File

@ -21,7 +21,7 @@ type Config struct {
func NewConfig(environment string) Config { func NewConfig(environment string) Config {
filenameWithExtension := fmt.Sprintf("%s.toml", environment) filenameWithExtension := fmt.Sprintf("%s.toml", environment)
absolutePath := filepath.Join(ProjectRoot(), "config", "environments", filenameWithExtension) absolutePath := filepath.Join(ProjectRoot(), "pkg", "config", "environments", filenameWithExtension)
config := parseConfigFile(absolutePath) config := parseConfigFile(absolutePath)
config.Client.IPCPath = filepath.Join(ProjectRoot(), config.Client.IPCPath) config.Client.IPCPath = filepath.Join(ProjectRoot(), config.Client.IPCPath)
return config return config
@ -29,7 +29,7 @@ func NewConfig(environment string) Config {
func ProjectRoot() string { func ProjectRoot() string {
var _, filename, _, _ = runtime.Caller(0) var _, filename, _, _ = runtime.Caller(0)
return path.Join(path.Dir(filename), "../") return path.Join(path.Dir(filename), "..", "..")
} }
func parseConfigFile(configfile string) Config { func parseConfigFile(configfile string) Config {

View File

@ -3,7 +3,7 @@ package config_test
import ( import (
"path/filepath" "path/filepath"
"github.com/8thlight/vulcanizedb/config" "github.com/8thlight/vulcanizedb/pkg/config"
. "github.com/onsi/ginkgo" . "github.com/onsi/ginkgo"
. "github.com/onsi/gomega" . "github.com/onsi/gomega"
) )

View File

@ -1,6 +1,6 @@
package fakes package fakes
import "github.com/8thlight/vulcanizedb/core" import "github.com/8thlight/vulcanizedb/pkg/core"
type Blockchain struct { type Blockchain struct {
outputBlocks chan core.Block outputBlocks chan core.Block

View File

@ -1,6 +1,6 @@
package fakes package fakes
import "github.com/8thlight/vulcanizedb/core" import "github.com/8thlight/vulcanizedb/pkg/core"
type BlockchainObserver struct { type BlockchainObserver struct {
CurrentBlocks []core.Block CurrentBlocks []core.Block

View File

@ -1,7 +1,7 @@
package geth package geth
import ( import (
"github.com/8thlight/vulcanizedb/core" "github.com/8thlight/vulcanizedb/pkg/core"
"github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/common/hexutil" "github.com/ethereum/go-ethereum/common/hexutil"
"github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/core/types"

View File

@ -3,7 +3,7 @@ package geth_test
import ( import (
"math/big" "math/big"
"github.com/8thlight/vulcanizedb/geth" "github.com/8thlight/vulcanizedb/pkg/geth"
"github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/common/hexutil" "github.com/ethereum/go-ethereum/common/hexutil"
"github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/core/types"

View File

@ -3,7 +3,7 @@ package geth
import ( import (
"fmt" "fmt"
"github.com/8thlight/vulcanizedb/core" "github.com/8thlight/vulcanizedb/pkg/core"
"github.com/ethereum/go-ethereum" "github.com/ethereum/go-ethereum"
"github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/ethclient" "github.com/ethereum/go-ethereum/ethclient"

View File

@ -1,8 +1,8 @@
package observers package observers
import ( import (
"github.com/8thlight/vulcanizedb/core" "github.com/8thlight/vulcanizedb/pkg/core"
"github.com/8thlight/vulcanizedb/repositories" "github.com/8thlight/vulcanizedb/pkg/repositories"
) )
type BlockchainDbObserver struct { type BlockchainDbObserver struct {

View File

@ -1,9 +1,9 @@
package observers_test package observers_test
import ( import (
"github.com/8thlight/vulcanizedb/core" "github.com/8thlight/vulcanizedb/pkg/core"
"github.com/8thlight/vulcanizedb/observers" "github.com/8thlight/vulcanizedb/pkg/observers"
"github.com/8thlight/vulcanizedb/repositories" "github.com/8thlight/vulcanizedb/pkg/repositories"
. "github.com/onsi/ginkgo" . "github.com/onsi/ginkgo"
. "github.com/onsi/gomega" . "github.com/onsi/gomega"
) )

View File

@ -4,7 +4,7 @@ import (
"fmt" "fmt"
"time" "time"
"github.com/8thlight/vulcanizedb/core" "github.com/8thlight/vulcanizedb/pkg/core"
) )
type BlockchainLoggingObserver struct{} type BlockchainLoggingObserver struct{}

View File

@ -1,7 +1,7 @@
package repositories package repositories
import ( import (
"github.com/8thlight/vulcanizedb/core" "github.com/8thlight/vulcanizedb/pkg/core"
) )
type InMemory struct { type InMemory struct {

View File

@ -1,8 +1,8 @@
package repositories_test package repositories_test
import ( import (
"github.com/8thlight/vulcanizedb/core" "github.com/8thlight/vulcanizedb/pkg/core"
"github.com/8thlight/vulcanizedb/repositories" "github.com/8thlight/vulcanizedb/pkg/repositories"
_ "github.com/lib/pq" _ "github.com/lib/pq"
. "github.com/onsi/ginkgo" . "github.com/onsi/ginkgo"
. "github.com/onsi/gomega" . "github.com/onsi/gomega"

View File

@ -3,7 +3,7 @@ package repositories
import ( import (
"database/sql" "database/sql"
"github.com/8thlight/vulcanizedb/core" "github.com/8thlight/vulcanizedb/pkg/core"
"github.com/jmoiron/sqlx" "github.com/jmoiron/sqlx"
_ "github.com/lib/pq" _ "github.com/lib/pq"
) )

View File

@ -1,9 +1,9 @@
package repositories_test package repositories_test
import ( import (
"github.com/8thlight/vulcanizedb/config" "github.com/8thlight/vulcanizedb/pkg/config"
"github.com/8thlight/vulcanizedb/core" "github.com/8thlight/vulcanizedb/pkg/core"
"github.com/8thlight/vulcanizedb/repositories" "github.com/8thlight/vulcanizedb/pkg/repositories"
"github.com/jmoiron/sqlx" "github.com/jmoiron/sqlx"
_ "github.com/lib/pq" _ "github.com/lib/pq"
. "github.com/onsi/ginkgo" . "github.com/onsi/ginkgo"

View File

@ -1,6 +1,6 @@
package repositories package repositories
import "github.com/8thlight/vulcanizedb/core" import "github.com/8thlight/vulcanizedb/pkg/core"
type Repository interface { type Repository interface {
CreateBlock(block core.Block) CreateBlock(block core.Block)