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// +build linux
15
16package sysfs
17
18import (
19	"testing"
20
21	"github.com/google/go-cmp/cmp"
22)
23
24func TestNVMeClass(t *testing.T) {
25	fs, err := NewFS(sysTestFixtures)
26	if err != nil {
27		t.Fatal(err)
28	}
29
30	got, err := fs.NVMeClass()
31	if err != nil {
32		t.Fatal(err)
33	}
34
35	want := NVMeClass{
36		"nvme0": NVMeDevice{
37			Name:             "nvme0",
38			FirmwareRevision: "1B2QEXP7",
39			Model:            "Samsung SSD 970 PRO 512GB",
40			Serial:           "S680HF8N190894I",
41			State:            "live",
42		},
43	}
44
45	if diff := cmp.Diff(want, got); diff != "" {
46		t.Fatalf("unexpected NVMe class (-want +got):\n%s", diff)
47	}
48}
49