forked from rancher-sandbox/rancher-desktop
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Mock KubeClient listServices for screenshots
Mock the `listServices` function of `KubeClient` to show some items on the list as part of the port forwarding page screenshot. Signed-off-by: Tatjana Dehler <[email protected]>
- Loading branch information
Tatjana Dehler
committed
Nov 2, 2023
1 parent
d913ac2
commit 5792886
Showing
6 changed files
with
69 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import semver from 'semver'; | ||
|
||
import { BackendSettings } from '@pkg/backend/backend'; | ||
import { KubeClient, ServiceEntry } from '@pkg/backend/kube/client'; | ||
import LimaKubernetesBackend from '@pkg/backend/kube/lima'; | ||
import WSLKubernetesBackend from '@pkg/backend/kube/wsl'; | ||
|
||
export class LimaKubernetesBackendMock extends LimaKubernetesBackend { | ||
start(config_: BackendSettings, kubernetesVersion: semver.SemVer): Promise<string> { | ||
return super.start(config_, kubernetesVersion, new KubeClientMock()); | ||
} | ||
} | ||
|
||
export class WSLKubernetesBackendMock extends WSLKubernetesBackend { | ||
start(config_: BackendSettings, kubernetesVersion: semver.SemVer): Promise<string> { | ||
return super.start(config_, kubernetesVersion, new KubeClientMock()); | ||
} | ||
} | ||
|
||
class KubeClientMock extends KubeClient { | ||
listServices(namespace: string | undefined = undefined): ServiceEntry[] { | ||
return [{ | ||
namespace: 'default', | ||
name: 'nginx', | ||
portName: 'http', | ||
port: 8080, | ||
listenPort: 30001, | ||
}, { | ||
namespace: 'default', | ||
name: 'wordpress', | ||
portName: 'http', | ||
port: 8080, | ||
}, { | ||
namespace: 'default', | ||
name: 'wordpress', | ||
portName: 'https', | ||
port: 443, | ||
}]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters