Skip to content

Commit a399138

Browse files
committed
add makefiles
1 parent 6b9c3c3 commit a399138

File tree

7 files changed

+195
-1
lines changed

7 files changed

+195
-1
lines changed

assert/Makefile

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
clean:
2+
rm -rf ./bin
3+
rm coverage.out
4+
5+
build:
6+
go build ./...
7+
8+
clean.build: clean build
9+
10+
fmt:
11+
gofmt -w ./
12+
13+
test:
14+
go clean -testcache
15+
go test ./... -cover -coverprofile=coverage.out
16+
17+
test.v:
18+
go clean -testcache
19+
go test ./... -cover -coverprofile=coverage.out -v
20+
21+
test.cov:
22+
go tool cover -html=coverage.out
23+
24+
test.bench:
25+
go clean -testcache
26+
go test -bench=. -benchmem
27+
28+
test.bench.profile:
29+
go clean -testcache
30+
go test -bench=. -benchmem -memprofile memory.out
31+
32+
.PHONY: test

box/Makefile

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
clean:
2+
rm -rf ./bin
3+
rm coverage.out
4+
5+
build:
6+
go build ./...
7+
8+
clean.build: clean build
9+
10+
fmt:
11+
gofmt -w ./
12+
13+
test:
14+
go clean -testcache
15+
go test ./... -cover -coverprofile=coverage.out
16+
17+
test.v:
18+
go clean -testcache
19+
go test ./... -cover -coverprofile=coverage.out -v
20+
21+
test.cov:
22+
go tool cover -html=coverage.out
23+
24+
test.bench:
25+
go clean -testcache
26+
go test -bench=. -benchmem
27+
28+
test.bench.profile:
29+
go clean -testcache
30+
go test -bench=. -benchmem -memprofile memory.out
31+
32+
.PHONY: test

gq/Makefile

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
clean:
2+
rm -rf ./bin
3+
rm coverage.out
4+
5+
build:
6+
go build ./...
7+
8+
clean.build: clean build
9+
10+
fmt:
11+
gofmt -w ./
12+
13+
test:
14+
go clean -testcache
15+
go test ./... -cover -coverprofile=coverage.out
16+
17+
test.v:
18+
go clean -testcache
19+
go test ./... -cover -coverprofile=coverage.out -v
20+
21+
test.cov:
22+
go tool cover -html=coverage.out
23+
24+
test.bench:
25+
go clean -testcache
26+
go test -bench=. -benchmem
27+
28+
test.bench.profile:
29+
go clean -testcache
30+
go test -bench=. -benchmem -memprofile memory.out
31+
32+
.PHONY: test

ordered_map/Makefile

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
clean:
2+
rm -rf ./bin
3+
rm coverage.out
4+
5+
build:
6+
go build ./...
7+
8+
clean.build: clean build
9+
10+
fmt:
11+
gofmt -w ./
12+
13+
test:
14+
go clean -testcache
15+
go test ./... -cover -coverprofile=coverage.out
16+
17+
test.v:
18+
go clean -testcache
19+
go test ./... -cover -coverprofile=coverage.out -v
20+
21+
test.cov:
22+
go tool cover -html=coverage.out
23+
24+
test.bench:
25+
go clean -testcache
26+
go test -bench=. -benchmem
27+
28+
test.bench.profile:
29+
go clean -testcache
30+
go test -bench=. -benchmem -memprofile memory.out
31+
32+
.PHONY: test

sqlx/Makefile

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
clean:
2+
rm -rf ./bin
3+
rm coverage.out
4+
5+
build:
6+
go build ./...
7+
8+
clean.build: clean build
9+
10+
fmt:
11+
gofmt -w ./
12+
13+
test:
14+
go clean -testcache
15+
go test ./... -cover -coverprofile=coverage.out
16+
17+
test.v:
18+
go clean -testcache
19+
go test ./... -cover -coverprofile=coverage.out -v
20+
21+
test.cov:
22+
go tool cover -html=coverage.out
23+
24+
test.bench:
25+
go clean -testcache
26+
go test -bench=. -benchmem
27+
28+
test.bench.profile:
29+
go clean -testcache
30+
go test -bench=. -benchmem -memprofile memory.out
31+
32+
.PHONY: test

sqlx/select.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ func (self SelectStatement) SqlPretty() string {
9494
columns := []string{}
9595

9696
for _, column := range self.columns {
97-
columns = append(columns, column.Sql())
97+
columns = append(columns, "\t"+column.Sql())
9898
}
9999

100100
parts = append(parts, strings.Join(columns, ",\n"))

sqlx/select_test.go

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,4 +113,38 @@ func TestSelect(t *testing.T) {
113113
}
114114
})
115115
})
116+
117+
t.Run("pretty", func(t *testing.T) {
118+
t.Run("column", func(t *testing.T) {
119+
t.Run("string", func(t *testing.T) {
120+
sql := sqlx.Select("a", "b", "c").SqlPretty()
121+
122+
if sql != "SELECT\n\ta,\n\tb,\n\tc;" {
123+
t.Fatalf(sql)
124+
}
125+
})
126+
127+
t.Run("select", func(t *testing.T) {
128+
sql := sqlx.Select().ColumnSelect(
129+
sqlx.Select("a", "b", "c").From("test"),
130+
"results",
131+
).SqlPretty()
132+
133+
if sql != "SELECT\n\t(SELECT a, b, c FROM test) as \"results\";" {
134+
t.Fatalf(sql)
135+
}
136+
})
137+
138+
// t.Run("string and select", func(t *testing.T) {
139+
// sql := sqlx.Select("1", "2").ColumnSelect(
140+
// sqlx.Select("a", "b", "c").From("test"),
141+
// "results",
142+
// ).Sql()
143+
144+
// if sql != "SELECT 1, 2, (SELECT a, b, c FROM test) as \"results\";" {
145+
// t.Fatalf(sql)
146+
// }
147+
// })
148+
})
149+
})
116150
}

0 commit comments

Comments
 (0)