github.com/thanos-io/thanos@v0.32.5/pkg/model/units_test.go (about)

     1  // Copyright (c) The Thanos Authors.
     2  // Licensed under the Apache License 2.0.
     3  
     4  package model
     5  
     6  import (
     7  	"testing"
     8  
     9  	"gopkg.in/yaml.v2"
    10  
    11  	"github.com/efficientgo/core/testutil"
    12  )
    13  
    14  func TestBytes_Marshaling(t *testing.T) {
    15  	value := Bytes(1048576)
    16  
    17  	encoded, err := yaml.Marshal(&value)
    18  	testutil.Ok(t, err)
    19  	testutil.Equals(t, "1MiB\n", string(encoded))
    20  
    21  	var decoded Bytes
    22  	err = yaml.Unmarshal(encoded, &decoded)
    23  	testutil.Equals(t, value, decoded)
    24  	testutil.Ok(t, err)
    25  }