forked from jfcote87/esign
-
Notifications
You must be signed in to change notification settings - Fork 0
/
connect_test.go
42 lines (38 loc) · 1.2 KB
/
connect_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
// Copyright 2019 James Cote
// All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package esign_test
import (
"bytes"
"encoding/xml"
"os"
"testing"
"time"
"github.com/jfcote87/esign"
)
func TestXML(t *testing.T) {
_ = bytes.NewBufferString("")
f, err := os.Open("testdata/connect.xml")
if err != nil {
t.Fatalf("Open Connect.xml: %v", err)
return
}
var v *esign.ConnectData = &esign.ConnectData{}
decoder := xml.NewDecoder(f)
err = decoder.Decode(v)
if err != nil {
t.Fatalf("XML Decode: %v", err)
return
}
if v.EnvelopeStatus.DocumentStatuses[0].Name != "Docusign1.pdf" {
t.Errorf("invalid document name in connect XML: %s", v.EnvelopeStatus.DocumentStatuses[0].Name)
}
var delivered = v.EnvelopeStatus.RecipientStatuses[0].Delivered
if !delivered.Time().Equal(time.Date(2014, 11, 11, 13, 43, 40, 887000000, time.UTC)) {
t.Errorf("expected Delivered = 2014-11-11 13:43:40.887 +0000 UTC; got %v", delivered.Time())
}
if !v.EnvelopeStatus.Signed.Time().Equal(time.Date(2014, 11, 11, 13, 44, 23, 590000000, time.UTC)) {
t.Errorf("expected Signed = 2014-11-11 13:43:45.3; got %v", v.EnvelopeStatus.Signed.Time())
}
}