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-*
test_data_dir/
vendor/
config/environments/*.toml
pkg/config/environments/*.toml

View File

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

View File

@ -5,7 +5,7 @@ import (
"fmt"
"github.com/8thlight/vulcanizedb/config"
"github.com/8thlight/vulcanizedb/pkg/config"
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.
* 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
## 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.
1. Run `./scripts/start_private_blockchain` as a separate process.
2. `go test ./...`
2. `go test ./...` to run all tests.
### Unit Tests
1. `go test ./core`
1. `go test ./pkg/...`

View File

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

View File

@ -1,25 +1,15 @@
package integration_test
import (
"path"
"runtime"
"github.com/8thlight/vulcanizedb/blockchain_listener"
"github.com/8thlight/vulcanizedb/core"
"github.com/8thlight/vulcanizedb/fakes"
"github.com/8thlight/vulcanizedb/geth"
"github.com/8thlight/vulcanizedb/pkg/blockchain_listener"
"github.com/8thlight/vulcanizedb/pkg/config"
"github.com/8thlight/vulcanizedb/pkg/core"
"github.com/8thlight/vulcanizedb/pkg/fakes"
"github.com/8thlight/vulcanizedb/pkg/geth"
. "github.com/onsi/ginkgo"
. "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 listener blockchain_listener.BlockchainListener
@ -27,7 +17,8 @@ var _ = Describe("Reading from the Geth blockchain", func() {
BeforeEach(func() {
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}
listener = blockchain_listener.NewBlockchainListener(blockchain, observers)
})

View File

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

View File

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

View File

@ -21,7 +21,7 @@ type Config struct {
func NewConfig(environment string) Config {
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.Client.IPCPath = filepath.Join(ProjectRoot(), config.Client.IPCPath)
return config
@ -29,7 +29,7 @@ func NewConfig(environment string) Config {
func ProjectRoot() string {
var _, filename, _, _ = runtime.Caller(0)
return path.Join(path.Dir(filename), "../")
return path.Join(path.Dir(filename), "..", "..")
}
func parseConfigFile(configfile string) Config {

View File

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

View File

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

View File

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

View File

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

View File

@ -3,7 +3,7 @@ package geth_test
import (
"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/hexutil"
"github.com/ethereum/go-ethereum/core/types"

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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