github.com/keltia/go-ipfs@v0.3.8-0.20150909044612-210793031c63/core/commands/diag_test.go (about)

     1  package commands
     2  
     3  import (
     4  	"bytes"
     5  	"testing"
     6  )
     7  
     8  func TestPrintDiagnostics(t *testing.T) {
     9  	output := DiagnosticOutput{
    10  		Peers: []DiagnosticPeer{
    11  			{ID: "QmNrjRuUtBNZAigzLRdZGN1YCNUxdF2WY2HnKyEFJqoTeg",
    12  				UptimeSeconds: 14,
    13  				Connections: []DiagnosticConnection{
    14  					{ID: "QmNrjRuUtBNZAigzLRdZGN1YCNUxdF2WY2HnKyEFJqoTeg",
    15  						NanosecondsLatency: 1347899,
    16  					},
    17  				},
    18  			},
    19  			{ID: "QmUaUZDp6QWJabBYSKfiNmXLAXD8HNKnWZh9Zoz6Zri9Ti",
    20  				UptimeSeconds: 14,
    21  			},
    22  		},
    23  	}
    24  	buf := new(bytes.Buffer)
    25  	if err := printDiagnostics(buf, &output); err != nil {
    26  		t.Fatal(err)
    27  	}
    28  	t.Log(buf.String())
    29  }