github.com/muyo/sno@v1.2.1/internal/time_test.go (about)

     1  package internal
     2  
     3  import (
     4  	"testing"
     5  	"time"
     6  )
     7  
     8  func testSnotime(t *testing.T) {
     9  	// Covers all arch/os combinations since they are expected to provide the snotime() function
    10  	// to the rest of the package.
    11  	//
    12  	// Strictly speaking this test can be flaky if the time.Now() call happens to cross
    13  	// the boundary between different TimeUnits, but that would just be really bad luck.
    14  	actual := Snotime()
    15  	expected := uint64(time.Now().UnixNano()-epochNsec) / timeUnit
    16  
    17  	if actual != expected {
    18  		t.Errorf("expected [%v], got [%v]", expected, actual)
    19  	}
    20  }