File tree Expand file tree Collapse file tree 2 files changed +28
-2
lines changed
Expand file tree Collapse file tree 2 files changed +28
-2
lines changed Original file line number Diff line number Diff line change 1+ package helpers
2+
3+ import (
4+ "fmt"
5+ "testing"
6+ )
7+
8+ func TestMarshalTimeDuration (t * testing.T ) {
9+ td := TimeDuration (2000000000 )
10+ expected := "\" 1s\" "
11+ err := td .UnmarshalJSON ([]byte (expected ))
12+ if err != nil {
13+ t .Errorf ("got error during unmarshal <%s>" , err )
14+ }
15+ json , err := td .MarshalJSON ()
16+ if err != nil {
17+ t .Errorf ("got error during marshal <%s>" , err )
18+ }
19+ if fmt .Sprintf ("%s" , json ) != expected {
20+ t .Errorf ("expected<%s> got %s" , expected , json )
21+ }
22+ }
Original file line number Diff line number Diff line change @@ -18,13 +18,13 @@ import (
1818type (
1919 // ElasticReloadCore Currently used ElasticReloadCore (as opposed to deprecated settings)
2020 ElasticReloadCore struct {
21- session.AppSelection
2221 // PollInterval time in-between polling for reload status
2322 PollInterval helpers.TimeDuration `json:"pollinterval" displayname:"Poll interval" doc-key:"elasticreload.pollinterval"`
2423 }
2524
2625 //ElasticReloadSettings specify app to reload
2726 ElasticReloadSettings struct {
27+ session.AppSelection
2828 ElasticReloadCore
2929 }
3030
@@ -66,7 +66,11 @@ func (settings *ElasticReloadSettings) UnmarshalJSON(arg []byte) error {
6666 if err := jsonit .Unmarshal (arg , & core ); err != nil {
6767 return errors .Wrapf (err , "failed to unmarshal action<%s>" , ActionElasticReload )
6868 }
69- * settings = ElasticReloadSettings {core }
69+ var appSelection session.AppSelection
70+ if err := jsonit .Unmarshal (arg , & appSelection ); err != nil {
71+ return errors .Wrapf (err , "failed to unmarshal action<%s>" , ActionOpenApp )
72+ }
73+ * settings = ElasticReloadSettings {appSelection , core }
7074 return nil
7175}
7276
You can’t perform that action at this time.
0 commit comments