-
Notifications
You must be signed in to change notification settings - Fork 2
/
entry_test.go
51 lines (39 loc) · 1.62 KB
/
entry_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
43
44
45
46
47
48
49
50
51
package hdsfhir
import (
"time"
fhir "github.com/intervention-engine/fhir/models"
. "gopkg.in/check.v1"
)
type EntrySuite struct {
}
var _ = Suite(&EntrySuite{})
func (s *EntrySuite) TestGetFHIRPeriod(c *C) {
entry := Entry{StartTime: NewUnixTime(1320148800), EndTime: NewUnixTime(1320152400)}
period := entry.GetFHIRPeriod()
c.Assert(period, FitsTypeOf, &fhir.Period{})
c.Assert(period.Start.Precision, Equals, fhir.Precision(fhir.Timestamp))
c.Assert(period.Start.Time.UTC(), Equals, time.Date(2011, time.November, 1, 12, 0, 0, 0, time.UTC))
c.Assert(period.End.Precision, Equals, fhir.Precision(fhir.Timestamp))
c.Assert(period.End.Time.UTC(), Equals, time.Date(2011, time.November, 1, 13, 0, 0, 0, time.UTC))
}
func (s *EntrySuite) TestGetFHIRPeriodWithNoStart(c *C) {
entry := Entry{EndTime: NewUnixTime(1320152400)}
period := entry.GetFHIRPeriod()
c.Assert(period, FitsTypeOf, &fhir.Period{})
c.Assert(period.Start, IsNil)
c.Assert(period.End.Precision, Equals, fhir.Precision(fhir.Timestamp))
c.Assert(period.End.Time.UTC(), Equals, time.Date(2011, time.November, 1, 13, 0, 0, 0, time.UTC))
}
func (s *EntrySuite) TestGetFHIRPeriodWithNoEnd(c *C) {
entry := Entry{StartTime: NewUnixTime(1320148800)}
period := entry.GetFHIRPeriod()
c.Assert(period, FitsTypeOf, &fhir.Period{})
c.Assert(period.Start.Precision, Equals, fhir.Precision(fhir.Timestamp))
c.Assert(period.Start.Time.UTC(), Equals, time.Date(2011, time.November, 1, 12, 0, 0, 0, time.UTC))
c.Assert(period.End, IsNil)
}
func (s *EntrySuite) TestGetFHIRPeriodWithNoStartOrEnd(c *C) {
entry := Entry{}
period := entry.GetFHIRPeriod()
c.Assert(period, IsNil)
}