...

Source file src/github.com/prometheus/procfs/sysfs/class_dmi_test.go

Documentation: github.com/prometheus/procfs/sysfs

     1  // Copyright 2021 The Prometheus Authors
     2  // Licensed under the Apache License, Version 2.0 (the "License");
     3  // you may not use this file except in compliance with the License.
     4  // You may obtain a copy of the License at
     5  //
     6  // http://www.apache.org/licenses/LICENSE-2.0
     7  //
     8  // Unless required by applicable law or agreed to in writing, software
     9  // distributed under the License is distributed on an "AS IS" BASIS,
    10  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    11  // See the License for the specific language governing permissions and
    12  // limitations under the License.
    13  
    14  //go:build linux
    15  // +build linux
    16  
    17  package sysfs
    18  
    19  import (
    20  	"testing"
    21  
    22  	"github.com/google/go-cmp/cmp"
    23  )
    24  
    25  func TestDMIClass(t *testing.T) {
    26  	fs, err := NewFS(sysTestFixtures)
    27  	if err != nil {
    28  		t.Fatal(err)
    29  	}
    30  
    31  	got, err := fs.DMIClass()
    32  	if err != nil {
    33  		t.Fatal(err)
    34  	}
    35  
    36  	empty := ""
    37  	biosDate := "04/12/2021"
    38  	biosRelease := "2.2"
    39  	biosVendor := "Dell Inc."
    40  	biosVersion := "2.2.4"
    41  	boardName := "07PXPY"
    42  	boardSerial := ".7N62AI2.GRTCL6944100GP."
    43  	boardVendor := "Dell Inc."
    44  	boardVersion := "A01"
    45  	chassisSerial := "7N62AI2"
    46  	chassisType := "23"
    47  	chassisVendor := "Dell Inc."
    48  	productFamily := "PowerEdge"
    49  	productName := "PowerEdge R6515"
    50  	productSerial := "7N62AI2"
    51  	productSKU := "SKU=NotProvided;ModelName=PowerEdge R6515"
    52  	productUUID := "83340ca8-cb49-4474-8c29-d2088ca84dd9"
    53  	systemVendor := "Dell Inc."
    54  
    55  	want := &DMIClass{
    56  		BiosDate:        &biosDate,
    57  		BiosRelease:     &biosRelease,
    58  		BiosVendor:      &biosVendor,
    59  		BiosVersion:     &biosVersion,
    60  		BoardName:       &boardName,
    61  		BoardSerial:     &boardSerial,
    62  		BoardVendor:     &boardVendor,
    63  		BoardVersion:    &boardVersion,
    64  		ChassisAssetTag: &empty,
    65  		ChassisSerial:   &chassisSerial,
    66  		ChassisType:     &chassisType,
    67  		ChassisVendor:   &chassisVendor,
    68  		ChassisVersion:  &empty,
    69  		ProductFamily:   &productFamily,
    70  		ProductName:     &productName,
    71  		ProductSerial:   &productSerial,
    72  		ProductSKU:      &productSKU,
    73  		ProductUUID:     &productUUID,
    74  		ProductVersion:  &empty,
    75  		SystemVendor:    &systemVendor,
    76  	}
    77  
    78  	if diff := cmp.Diff(want, got); diff != "" {
    79  		t.Fatalf("unexpected DMI class (-want +got):\n%s", diff)
    80  	}
    81  }
    82  

View as plain text