...

Source file src/github.com/letsencrypt/boulder/observer/mon_conf_test.go

Documentation: github.com/letsencrypt/boulder/observer

     1  package observer
     2  
     3  import (
     4  	"testing"
     5  	"time"
     6  
     7  	"github.com/letsencrypt/boulder/config"
     8  	"github.com/letsencrypt/boulder/test"
     9  )
    10  
    11  func TestMonConf_validatePeriod(t *testing.T) {
    12  	type fields struct {
    13  		Period config.Duration
    14  	}
    15  	tests := []struct {
    16  		name    string
    17  		fields  fields
    18  		wantErr bool
    19  	}{
    20  		{"valid", fields{config.Duration{Duration: 1 * time.Microsecond}}, false},
    21  		{"1 nanosecond", fields{config.Duration{Duration: 1 * time.Nanosecond}}, true},
    22  		{"none supplied", fields{config.Duration{}}, true},
    23  	}
    24  	for _, tt := range tests {
    25  		t.Run(tt.name, func(t *testing.T) {
    26  			c := &MonConf{
    27  				Period: tt.fields.Period,
    28  			}
    29  			err := c.validatePeriod()
    30  			if tt.wantErr {
    31  				test.AssertError(t, err, "MonConf.validatePeriod() should have errored")
    32  			} else {
    33  				test.AssertNotError(t, err, "MonConf.validatePeriod() shouldn't have errored")
    34  			}
    35  		})
    36  	}
    37  }
    38  

View as plain text