github.com/instana/go-sensor@v1.62.2-0.20240520081010-4919868049e1/process/stats_reader_test.go (about) 1 // (c) Copyright IBM Corp. 2024 2 3 //go:build !linux 4 // +build !linux 5 6 package process 7 8 import ( 9 "reflect" 10 "testing" 11 ) 12 13 func TestStats(t *testing.T) { 14 tests := []struct { 15 name string 16 want statsReader 17 }{ 18 { 19 name: "success", 20 want: statsReader{}, 21 }, 22 } 23 for _, tt := range tests { 24 t.Run(tt.name, func(t *testing.T) { 25 if got := Stats(); !reflect.DeepEqual(got, tt.want) { 26 t.Errorf("Stats() = %v, want %v", got, tt.want) 27 } 28 }) 29 } 30 } 31 32 func Test_statsReader_Memory(t *testing.T) { 33 tests := []struct { 34 name string 35 want MemStats 36 wantErr bool 37 }{ 38 { 39 name: "success", 40 want: MemStats{}, 41 wantErr: false, 42 }, 43 } 44 for _, tt := range tests { 45 t.Run(tt.name, func(t *testing.T) { 46 s := statsReader{} 47 got, err := s.Memory() 48 if (err != nil) != tt.wantErr { 49 t.Errorf("statsReader.Memory() error = %v, wantErr %v", err, tt.wantErr) 50 return 51 } 52 if !reflect.DeepEqual(got, tt.want) { 53 t.Errorf("statsReader.Memory() = %v, want %v", got, tt.want) 54 } 55 }) 56 } 57 } 58 59 func Test_statsReader_CPU(t *testing.T) { 60 tests := []struct { 61 name string 62 want CPUStats 63 want1 int 64 wantErr bool 65 }{ 66 { 67 name: "success", 68 want: CPUStats{}, 69 want1: 0, 70 wantErr: false, 71 }, 72 } 73 for _, tt := range tests { 74 t.Run(tt.name, func(t *testing.T) { 75 s := statsReader{} 76 got, got1, err := s.CPU() 77 if (err != nil) != tt.wantErr { 78 t.Errorf("statsReader.CPU() error = %v, wantErr %v", err, tt.wantErr) 79 return 80 } 81 if !reflect.DeepEqual(got, tt.want) { 82 t.Errorf("statsReader.CPU() got = %v, want %v", got, tt.want) 83 } 84 if got1 != tt.want1 { 85 t.Errorf("statsReader.CPU() got1 = %v, want %v", got1, tt.want1) 86 } 87 }) 88 } 89 } 90 91 func Test_statsReader_Limits(t *testing.T) { 92 tests := []struct { 93 name string 94 want ResourceLimits 95 wantErr bool 96 }{ 97 { 98 name: "success", 99 want: ResourceLimits{}, 100 wantErr: false, 101 }, 102 } 103 for _, tt := range tests { 104 t.Run(tt.name, func(t *testing.T) { 105 s := statsReader{} 106 got, err := s.Limits() 107 if (err != nil) != tt.wantErr { 108 t.Errorf("statsReader.Limits() error = %v, wantErr %v", err, tt.wantErr) 109 return 110 } 111 if !reflect.DeepEqual(got, tt.want) { 112 t.Errorf("statsReader.Limits() = %v, want %v", got, tt.want) 113 } 114 }) 115 } 116 }