(t *testing.T)
| 1576 | } |
| 1577 | |
| 1578 | func TestServiceV2_ListHosts(t *testing.T) { |
| 1579 | tests := []struct { |
| 1580 | name string |
| 1581 | mock func(host *standard.Host, hostManager standard.HostManager, mr *standard.MockResourceMockRecorder, mh *standard.MockHostManagerMockRecorder) |
| 1582 | expect func(t *testing.T, host *standard.Host, resp []*commonv2.Host, err error) |
| 1583 | }{ |
| 1584 | { |
| 1585 | name: "host manager is empty", |
| 1586 | mock: func(host *standard.Host, hostManager standard.HostManager, mr *standard.MockResourceMockRecorder, mh *standard.MockHostManagerMockRecorder) { |
| 1587 | gomock.InOrder( |
| 1588 | mr.HostManager().Return(hostManager).Times(1), |
| 1589 | mh.Range(gomock.Any()).Do(func(f func(key, value any) bool) { |
| 1590 | f(nil, nil) |
| 1591 | }).Return().Times(1), |
| 1592 | ) |
| 1593 | }, |
| 1594 | expect: func(t *testing.T, host *standard.Host, resp []*commonv2.Host, err error) { |
| 1595 | assert := assert.New(t) |
| 1596 | assert.NoError(err) |
| 1597 | assert.Equal(len(resp), 0) |
| 1598 | }, |
| 1599 | }, |
| 1600 | { |
| 1601 | name: "host manager is not empty", |
| 1602 | mock: func(host *standard.Host, hostManager standard.HostManager, mr *standard.MockResourceMockRecorder, mh *standard.MockHostManagerMockRecorder) { |
| 1603 | gomock.InOrder( |
| 1604 | mr.HostManager().Return(hostManager).Times(1), |
| 1605 | mh.Range(gomock.Any()).Do(func(f func(key, value any) bool) { |
| 1606 | f(nil, host) |
| 1607 | }).Return().Times(1), |
| 1608 | ) |
| 1609 | }, |
| 1610 | expect: func(t *testing.T, host *standard.Host, resp []*commonv2.Host, err error) { |
| 1611 | assert := assert.New(t) |
| 1612 | assert.NoError(err) |
| 1613 | assert.Equal(len(resp), 1) |
| 1614 | assert.EqualValues(resp[0], &commonv2.Host{ |
| 1615 | Id: mockHostID, |
| 1616 | Type: uint32(pkgtypes.HostTypeNormal), |
| 1617 | Hostname: "foo", |
| 1618 | Ip: "127.0.0.1", |
| 1619 | Port: 8003, |
| 1620 | DownloadPort: mockRawHost.DownloadPort, |
| 1621 | ProxyPort: mockRawHost.ProxyPort, |
| 1622 | Cpu: &commonv2.CPU{ |
| 1623 | LogicalCount: mockCPU.LogicalCount, |
| 1624 | PhysicalCount: mockCPU.PhysicalCount, |
| 1625 | Percent: mockCPU.Percent, |
| 1626 | ProcessPercent: mockCPU.ProcessPercent, |
| 1627 | Times: &commonv2.CPUTimes{ |
| 1628 | User: mockCPU.Times.User, |
| 1629 | System: mockCPU.Times.System, |
| 1630 | Idle: mockCPU.Times.Idle, |
| 1631 | Nice: mockCPU.Times.Nice, |
| 1632 | Iowait: mockCPU.Times.Iowait, |
| 1633 | Irq: mockCPU.Times.Irq, |
| 1634 | Softirq: mockCPU.Times.Softirq, |
| 1635 | Steal: mockCPU.Times.Steal, |
nothing calls this directly
no test coverage detected