Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
H
homekeeper
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Peter Cheng
homekeeper
Commits
abf29211
Commit
abf29211
authored
Sep 03, 2019
by
Peter Cheng
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
1.修正Status變數型態
2.追加測試碼
parent
c948a641
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
104 additions
and
8 deletions
+104
-8
hyperledgerREST.pb.go
beans/hyperledgerREST.pb.go
+6
-6
hyperledgerREST.proto
beans/hyperledgerREST.proto
+1
-1
base.go
controllers/base.go
+1
-1
base_test.go
controllers/base_test.go
+62
-0
mail_test.go
controllers/mail_test.go
+34
-0
No files found.
beans/hyperledgerREST.pb.go
View file @
abf29211
...
...
@@ -156,7 +156,7 @@ type APIError struct {
StatusCode
int32
` protobuf:"varint,6,opt,name=statusCode" json:"statusCode,omitempty"`
Name
string
` protobuf:"bytes,7,opt,name=name" json:"name,omitempty"`
Message
string
` protobuf:"bytes,8,opt,name=message" json:"message,omitempty"`
Status
string
` protobuf:"bytes,9,opt,name=status"
json:"status,omitempty"`
Status
int32
` protobuf:"varint,9,opt,name=status"
json:"status,omitempty"`
Code
string
` protobuf:"bytes,10,opt,name=code" json:"code,omitempty"`
Stack
string
` protobuf:"bytes,11,opt,name=stack" json:"stack,omitempty"`
}
...
...
@@ -187,11 +187,11 @@ func (m *APIError) GetMessage() string {
return
""
}
func
(
m
*
APIError
)
GetStatus
()
string
{
func
(
m
*
APIError
)
GetStatus
()
int32
{
if
m
!=
nil
{
return
m
.
Status
}
return
""
return
0
}
func
(
m
*
APIError
)
GetCode
()
string
{
...
...
@@ -237,7 +237,7 @@ var fileDescriptor0 = []byte{
0xd5
,
0xda
,
0xa7
,
0x07
,
0xad
,
0x82
,
0x99
,
0x7b
,
0x95
,
0xe6
,
0xfa
,
0xa8
,
0x46
,
0x62
,
0x45
,
0xd8
,
0x08
,
0xbd
,
0x81
,
0x1f
,
0x57
,
0x08
,
0x63
,
0x50
,
0xcf
,
0x4d
,
0x8c
,
0x4d
,
0xfb
,
0x2f
,
0x5b
,
0x33
,
0x84
,
0x66
,
0x46
,
0x4a
,
0xf1
,
0x0d
,
0x61
,
0xcb
,
0xe2
,
0x42
,
0xb2
,
0x1b
,
0x68
,
0xb8
,
0x59
,
0x6c
,
0xdb
,
0x
c6
,
0x59
,
0x99
,
0x2d
,
0x89
,
0xd9
,
0x0f
,
0x6e
,
0x8b
,
0xa9
,
0x4d
,
0x9e
,
0x4a
,
0xf3
,
0x64
,
0x
8f
,
0x81
,
0xcb
,
0xd3
,
0x8a
,
0x65
,
0xc3
,
0x3e
,
0x94
,
0xa7
,
0x9f
,
0x00
,
0x00
,
0x00
,
0xff
,
0xff
,
0x
ce
,
0xc4
,
0x57
,
0xe3
,
0x41
,
0x02
,
0x00
,
0x00
,
0xdb
,
0x
4d
,
0x67
,
0x65
,
0xb6
,
0x24
,
0x66
,
0x3f
,
0xb8
,
0x2d
,
0xa6
,
0x36
,
0x79
,
0x2a
,
0xcd
,
0x93
,
0x
3d
,
0x06
,
0x2e
,
0x4f
,
0x2b
,
0x96
,
0x0d
,
0xfb
,
0x50
,
0x9e
,
0x7e
,
0x02
,
0x00
,
0x00
,
0xff
,
0xff
,
0x
41
,
0xf6
,
0x94
,
0x61
,
0x41
,
0x02
,
0x00
,
0x00
,
}
beans/hyperledgerREST.proto
View file @
abf29211
...
...
@@ -24,7 +24,7 @@ message APIError {
int32
statusCode
=
6
;
//`json:"status_code" form:"status_code"`
string
name
=
7
;
//`json:"name" form:"name"`
string
message
=
8
;
//`json:"message" form:"message"`
string
status
=
9
;
//`json:"status" form:"status"`
int32
status
=
9
;
//`json:"status" form:"status"`
string
code
=
10
;
//`json:"code" form:"code"`
string
stack
=
11
;
//`json:"stack" form:"stack"`
}
\ No newline at end of file
controllers/base.go
View file @
abf29211
...
...
@@ -72,7 +72,7 @@ func getChainParams(url string, params []byte, action string, resultObject Chain
log
.
Panicln
(
err
)
return
}
if
resultObject
.
GetError
()
!=
nil
{
if
resultObject
.
GetError
()
!=
nil
&&
resultObject
.
GetError
()
.
GetStatusCode
()
!=
404
{
log
.
Panicln
(
resultObject
.
GetError
()
.
GetMessage
())
return
}
...
...
controllers/base_test.go
0 → 100644
View file @
abf29211
package
controllers
import
(
"reflect"
"testing"
)
func
TestGetURL
(
t
*
testing
.
T
)
{
type
args
struct
{
url
string
}
tests
:=
[]
struct
{
name
string
args
args
want
[]
byte
}{
{
name
:
"一般測試"
,
args
:
args
{
url
:
"https://ipfs.globalupload.io/QmWqePaG57UJhcZyt1cKMPh8ZfqdnoEueaR7JpS7r6vbLy"
,
},
want
:
[]
byte
(
"{
\n
\"
status
\"
: true,
\n
\"
subject
\"
:
\"
test
\"
,
\n
\"
content
\"
:
\"
this is a REST API test
\"\n
}"
),
},
}
for
_
,
tt
:=
range
tests
{
t
.
Run
(
tt
.
name
,
func
(
t
*
testing
.
T
)
{
got
:=
GetURL
(
tt
.
args
.
url
)
if
!
reflect
.
DeepEqual
(
got
,
tt
.
want
)
{
t
.
Errorf
(
"GetURL() = %v, want %v"
,
got
,
tt
.
want
)
}
})
}
}
func
TestPostURL
(
t
*
testing
.
T
)
{
type
args
struct
{
url
string
params
[]
byte
}
tests
:=
[]
struct
{
name
string
args
args
want
[]
byte
}{
{
name
:
"一般測試"
,
args
:
args
{
url
:
"https://ipfs.globalupload.io/QmWqePaG57UJhcZyt1cKMPh8ZfqdnoEueaR7JpS7r6vbLy"
,
params
:
[]
byte
(
"{
\"
status
\"
: true,
\"
subject
\"
:
\"
test
\"
,
\"
content
\"
:
\"
this is a REST API test
\"
}"
),
},
want
:
[]
byte
(
"Method POST not allowed: read only access"
),
},
}
for
_
,
tt
:=
range
tests
{
t
.
Run
(
tt
.
name
,
func
(
t
*
testing
.
T
)
{
got
:=
PostURL
(
tt
.
args
.
url
,
tt
.
args
.
params
)
if
!
reflect
.
DeepEqual
(
got
,
tt
.
want
)
{
t
.
Errorf
(
"PostURL() = %v, want %v"
,
got
,
tt
.
want
)
}
})
}
}
controllers/mail_test.go
0 → 100644
View file @
abf29211
package
controllers
import
(
"testing"
"github.com/teed7334-restore/homekeeper/beans"
)
func
Test_doSendMail
(
t
*
testing
.
T
)
{
type
args
struct
{
params
*
beans
.
SendMail
}
tests
:=
[]
struct
{
name
string
args
args
}{
{
name
:
"一般測試"
,
args
:
args
{
params
:
&
beans
.
SendMail
{
To
:
"teed7334@gmail.com"
,
Cc
:
"teed7334@163.com"
,
Subject
:
"這是一封測試信"
,
Content
:
"這是一封測試信"
,
},
},
},
}
for
_
,
tt
:=
range
tests
{
t
.
Run
(
tt
.
name
,
func
(
t
*
testing
.
T
)
{
doSendMail
(
tt
.
args
.
params
)
})
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment