...

Source file src/github.com/magiconair/properties/properties_go1.15_test.go

Documentation: github.com/magiconair/properties

     1  //go:build go1.15
     2  // +build go1.15
     3  
     4  package properties
     5  
     6  import (
     7  	"testing"
     8  	"time"
     9  
    10  	"github.com/magiconair/properties/assert"
    11  )
    12  
    13  // TestMustGetParsedDuration works with go1.15 and beyond where the panic
    14  // message was changed slightly. We keep this test (!) here to demonstrate the
    15  // backwards compatibility and to keep the author happy as long as it does not
    16  // affect any real users. Thank you! Frank :)
    17  //
    18  // See https://github.com/magiconair/properties/pull/63
    19  func TestMustGetParsedDuration(t *testing.T) {
    20  	input := "key = 123ms\nkey2 = ghi"
    21  	p := mustParse(t, input)
    22  	assert.Equal(t, p.MustGetParsedDuration("key"), 123*time.Millisecond)
    23  	assert.Panic(t, func() { p.MustGetParsedDuration("key2") }, `time: invalid duration "ghi"`)
    24  	assert.Panic(t, func() { p.MustGetParsedDuration("invalid") }, "unknown property: invalid")
    25  }
    26  

View as plain text