Skip to content

Commit 1ce7e77

Browse files
authored
fix GetDiff to use executeRaw() internally. (#84)
1 parent 3ae508e commit 1ce7e77

File tree

4 files changed

+57
-15
lines changed

4 files changed

+57
-15
lines changed

Makefile

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,23 @@
11
.DEFAULT_GOAL := help
22

33
env: ## check env for e2e testing
4-
ifndef BITBUCKET_TEST_USERNAME
5-
$(error `BITBUCKET_TEST_USERNAME` is not set)
6-
endif
7-
ifndef BITBUCKET_TEST_PASSWORD
8-
$(error `BITBUCKET_TEST_PASSWORD` is not set)
9-
endif
10-
ifndef BITBUCKET_TEST_OWNER
11-
$(error `BITBUCKET_TEST_OWNER` is not set)
12-
endif
13-
ifndef BITBUCKET_TEST_REPOSLUG
14-
$(error `BITBUCKET_TEST_REPOSLUG` is not set)
15-
endif
4+
ifndef BITBUCKET_TEST_USERNAME
5+
$(error `BITBUCKET_TEST_USERNAME` is not set)
6+
endif
7+
ifndef BITBUCKET_TEST_PASSWORD
8+
$(error `BITBUCKET_TEST_PASSWORD` is not set)
9+
endif
10+
ifndef BITBUCKET_TEST_OWNER
11+
$(error `BITBUCKET_TEST_OWNER` is not set)
12+
endif
13+
ifndef BITBUCKET_TEST_REPOSLUG
14+
$(error `BITBUCKET_TEST_REPOSLUG` is not set)
15+
endif
1616

1717
test: env ## run go test all
1818
go test -v ./tests
1919

20-
help: ## print this help
20+
help: ## print this help
2121
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
2222

2323
.PHONY: test help

diff.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ type Diff struct {
66

77
func (d *Diff) GetDiff(do *DiffOptions) (interface{}, error) {
88
urlStr := d.c.requestUrl("/repositories/%s/%s/diff/%s", do.Owner, do.RepoSlug, do.Spec)
9-
return d.c.execute("GET", urlStr, "")
9+
return d.c.executeRaw("GET", urlStr, "diff")
1010
}
1111

1212
func (d *Diff) GetPatch(do *DiffOptions) (interface{}, error) {

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ module github.com/ktrysmt/go-bitbucket
33
go 1.12
44

55
require (
6-
github.com/golang/protobuf v1.0.0 // indirect
6+
github.com/golang/protobuf v1.0.0
77
github.com/k0kubun/colorstring v0.0.0-20150214042306-9440f1994b88 // indirect
88
github.com/k0kubun/pp v2.3.0+incompatible
99
github.com/mattn/go-colorable v0.0.9 // indirect

tests/diff_test.go

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
package tests
2+
3+
import (
4+
"os"
5+
"testing"
6+
7+
"github.com/k0kubun/pp"
8+
"github.com/ktrysmt/go-bitbucket"
9+
)
10+
11+
func TestDiff(t *testing.T) {
12+
13+
user := os.Getenv("BITBUCKET_TEST_USERNAME")
14+
pass := os.Getenv("BITBUCKET_TEST_PASSWORD")
15+
owner := os.Getenv("BITBUCKET_TEST_OWNER")
16+
repo := os.Getenv("BITBUCKET_TEST_REPOSLUG")
17+
18+
if user == "" {
19+
t.Error("BITBUCKET_TEST_USERNAME is empty.")
20+
}
21+
22+
if pass == "" {
23+
t.Error("BITBUCKET_TEST_PASSWORD is empty.")
24+
}
25+
26+
c := bitbucket.NewBasicAuth(user, pass)
27+
28+
spec := "master..develop"
29+
30+
opt := &bitbucket.DiffOptions{
31+
Owner: owner,
32+
RepoSlug: repo,
33+
Spec: spec,
34+
}
35+
res, _ := c.Repositories.Diff.GetDiff(opt)
36+
37+
pp.Println(res)
38+
39+
if res == nil {
40+
t.Error("It could not get the raw response.")
41+
}
42+
}

0 commit comments

Comments
 (0)