MCPcopy
hub / github.com/google/uuid / TestNode

Function TestNode

uuid_test.go:345–387  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

343}
344
345func TestNode(t *testing.T) {
346 // This test is mostly to make sure we don't leave nodeMu locked.
347 ifname = ""
348 if ni := NodeInterface(); ni != "" {
349 t.Errorf("NodeInterface got %q, want %q", ni, "")
350 }
351 if SetNodeInterface("xyzzy") {
352 t.Error("SetNodeInterface succeeded on a bad interface name")
353 }
354 if !SetNodeInterface("") {
355 t.Error("SetNodeInterface failed")
356 }
357 if runtime.GOARCH != "js" {
358 if ni := NodeInterface(); ni == "" {
359 t.Error("NodeInterface returned an empty string")
360 }
361 }
362
363 ni := NodeID()
364 if len(ni) != 6 {
365 t.Errorf("ni got %d bytes, want 6", len(ni))
366 }
367 hasData := false
368 for _, b := range ni {
369 if b != 0 {
370 hasData = true
371 }
372 }
373 if !hasData {
374 t.Error("nodeid is all zeros")
375 }
376
377 id := []byte{1, 2, 3, 4, 5, 6, 7, 8}
378 SetNodeID(id)
379 ni = NodeID()
380 if !bytes.Equal(ni, id[:6]) {
381 t.Errorf("got nodeid %v, want %v", ni, id[:6])
382 }
383
384 if ni := NodeInterface(); ni != "user" {
385 t.Errorf("got interface %q, want %q", ni, "user")
386 }
387}
388
389func TestNodeAndTime(t *testing.T) {
390 // Time is February 5, 1998 12:30:23.136364800 AM GMT

Callers

nothing calls this directly

Calls 5

NodeInterfaceFunction · 0.85
SetNodeInterfaceFunction · 0.85
NodeIDFunction · 0.85
SetNodeIDFunction · 0.85
ErrorMethod · 0.45

Tested by

no test coverage detected