Skip to content

Commit b98c1fa

Browse files
committed
Expose vars pkg and some interfaces
1 parent 1a17da4 commit b98c1fa

29 files changed

+39
-29
lines changed

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,5 @@ data/*
66
coverage.txt
77
.github
88
dist
9+
.vscode
10+
.idea

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,7 @@ You can extract information from the request body too, using a dot notation path
244244
- request.body."*key*" (support for `application/json`, `application/xml` and `application/x-www-form-urlencoded` requests)
245245
- request.body."*deep*"."*key*" (support for `application/json`, `application/xml` requests)
246246

247-
Quick overview of the path syntax available to extract values form the request: [https://github.com/tidwall/gjson#path-syntax] (https://github.com/tidwall/gjson#path-syntax)
247+
Quick overview of the path syntax available to extract values form the request: [https://github.com/tidwall/gjson#path-syntax](https://github.com/tidwall/gjson#path-syntax)
248248

249249
**External streams:** Perfect for embedding big payloads or getting data from another service.
250250

cmd/mmock/main.go

+8-7
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,17 @@ import (
1010
"path/filepath"
1111
"strings"
1212

13-
"github.com/jmartin82/mmock/internal/config"
14-
"github.com/jmartin82/mmock/internal/config/parser"
1513
"github.com/jmartin82/mmock/internal/console"
14+
"github.com/jmartin82/mmock/internal/fs"
15+
"github.com/jmartin82/mmock/internal/fs/parser"
1616
"github.com/jmartin82/mmock/internal/server"
1717
"github.com/jmartin82/mmock/internal/statistics"
18-
"github.com/jmartin82/mmock/internal/vars"
19-
"github.com/jmartin82/mmock/internal/vars/fake"
18+
"github.com/jmartin82/mmock/pkg/config"
2019
"github.com/jmartin82/mmock/pkg/match"
2120
"github.com/jmartin82/mmock/pkg/match/payload"
2221
"github.com/jmartin82/mmock/pkg/mock"
22+
"github.com/jmartin82/mmock/pkg/vars"
23+
"github.com/jmartin82/mmock/pkg/vars/fake"
2324
)
2425

2526
//VERSION of the application
@@ -95,16 +96,16 @@ func getMapping(path string) config.Mapping {
9596
log.Fatalln(ErrNotFoundPath.Error())
9697
}
9798

98-
fsMapper := config.NewFileSystemMapper()
99+
fsMapper := fs.NewFileSystemMapper()
99100
fsMapper.AddParser(parser.JSONReader{})
100101
fsMapper.AddParser(parser.YAMLReader{})
101102

102103
fsUpdate := make(chan struct{})
103104

104-
watcher := config.NewFileWatcher(path, fsUpdate)
105+
watcher := fs.NewFileWatcher(path, fsUpdate)
105106
watcher.Bind()
106107

107-
return config.NewConfigMapping(path, fsMapper, fsUpdate)
108+
return fs.NewConfigMapping(path, fsMapper, fsUpdate)
108109
}
109110

110111
func getRouter(mapping config.Mapping, checker match.Matcher) *server.Router {

internal/console/dispatcher.go

+4-3
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ package console
33
import (
44
"errors"
55
"fmt"
6-
"github.com/jmartin82/mmock/internal/config"
76
"log"
87
"net/http"
98
"regexp"
@@ -12,9 +11,11 @@ import (
1211
"strings"
1312

1413
assetfs "github.com/elazarl/go-bindata-assetfs"
15-
"github.com/jmartin82/mmock/pkg/mock"
14+
"github.com/jmartin82/mmock/pkg/config"
1615
"github.com/jmartin82/mmock/pkg/match"
17-
"github.com/jmartin82/mmock/internal/statistics"
16+
"github.com/jmartin82/mmock/pkg/mock"
17+
18+
"github.com/jmartin82/mmock/internal/statistics"
1819
"github.com/labstack/echo"
1920
"golang.org/x/net/websocket"
2021
)

internal/config/filesystem.go renamed to internal/fs/filesystem.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package config
1+
package fs
22

33
import (
44
"encoding/json"

internal/config/filesystem_test.go renamed to internal/fs/filesystem_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package config
1+
package fs
22

33
import (
44
"errors"

internal/config/mapping.go renamed to internal/fs/mapping.go

+1-8
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package config
1+
package fs
22

33
import (
44
"errors"
@@ -15,13 +15,6 @@ import (
1515
var ErrFilePathIsNotUnderConfigPath = errors.New("File path is not under config path")
1616
var ErrMockDoesntExist = errors.New("Definition doesn't exist")
1717

18-
type Mapping interface {
19-
Set(URI string, mock mock.Definition) error
20-
Delete(URI string) error
21-
Get(URI string) (mock.Definition, bool)
22-
List() []mock.Definition
23-
}
24-
2518
//PrioritySort mock array sorted by priority
2619
type PrioritySort []mock.Definition
2720

internal/config/mapping_test.go renamed to internal/fs/mapping_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package config
1+
package fs
22

33
import (
44
"github.com/jmartin82/mmock/pkg/mock"

internal/config/watcher.go renamed to internal/fs/watcher.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package config
1+
package fs
22

33
import (
44
"log"

internal/config/watcher_test.go renamed to internal/fs/watcher_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package config
1+
package fs
22

33
import (
44
"io/ioutil"

internal/server/dispatcher.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ import (
2222
"strings"
2323

2424
"github.com/jmartin82/mmock/internal/statistics"
25-
"github.com/jmartin82/mmock/internal/vars"
25+
"github.com/jmartin82/mmock/pkg/vars"
2626
"github.com/jmartin82/mmock/pkg/mock"
2727
)
2828

internal/server/router.go

+5-2
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,13 @@ package server
33
import (
44
"bytes"
55
"encoding/gob"
6-
"github.com/jmartin82/mmock/internal/config"
7-
"github.com/jmartin82/mmock/pkg/mock"
6+
7+
"github.com/jmartin82/mmock/pkg/config"
8+
89
"log"
910

11+
"github.com/jmartin82/mmock/pkg/mock"
12+
1013
"github.com/jmartin82/mmock/pkg/match"
1114
)
1215

pkg/config/mapping.go

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
package config
2+
3+
import "github.com/jmartin82/mmock/pkg/mock"
4+
5+
type Mapping interface {
6+
Set(URI string, mock mock.Definition) error
7+
Delete(URI string) error
8+
Get(URI string) (mock.Definition, bool)
9+
List() []mock.Definition
10+
}
File renamed without changes.
File renamed without changes.

internal/vars/fake.go renamed to pkg/vars/fake.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ package vars
22

33
import (
44
"errors"
5-
"github.com/jmartin82/mmock/internal/vars/fake"
5+
"github.com/jmartin82/mmock/pkg/vars/fake"
66
"log"
77
"reflect"
88
"regexp"
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

internal/vars/filler.go renamed to pkg/vars/filler.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package vars
22

33
import (
4-
"github.com/jmartin82/mmock/internal/vars/fake"
4+
"github.com/jmartin82/mmock/pkg/vars/fake"
55
"github.com/jmartin82/mmock/pkg/mock"
66
)
77

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)