-
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.
send telemetry related to krunkit (#8680)
* feat: send telemetry related to krunkit Signed-off-by: Philippe Martin <[email protected]> * test: add unit tests for sendTelemetryRecords Signed-off-by: Philippe Martin <[email protected]> * feat: send telemetry when stop machine Signed-off-by: Philippe Martin <[email protected]> * fix: send provider code instead of label Signed-off-by: Philippe Martin <[email protected]> * chore: keep qemu-helper for future use on Linux Signed-off-by: Philippe Martin <[email protected]> --------- Signed-off-by: Philippe Martin <[email protected]>
- Loading branch information
Showing
4 changed files
with
289 additions
and
27 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
/********************************************************************** | ||
* Copyright (C) 2024 Red Hat, Inc. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
***********************************************************************/ | ||
|
||
import * as extensionApi from '@podman-desktop/api'; | ||
import type { Mock } from 'vitest'; | ||
import { beforeEach, expect, test, vi } from 'vitest'; | ||
|
||
import { KrunkitHelper } from './krunkit-helper'; | ||
|
||
let krunkitHelper: KrunkitHelper; | ||
|
||
// mock the API | ||
vi.mock('@podman-desktop/api', async () => { | ||
return { | ||
process: { | ||
exec: vi.fn(), | ||
}, | ||
}; | ||
}); | ||
|
||
beforeEach(() => { | ||
krunkitHelper = new KrunkitHelper(); | ||
vi.resetAllMocks(); | ||
}); | ||
|
||
test('should grab correct version', async () => { | ||
const output = `krunkit 0.1.2 | ||
`; | ||
|
||
(extensionApi.process.exec as Mock).mockReturnValue({ | ||
stdout: output, | ||
} as extensionApi.RunResult); | ||
|
||
// use a specific arch for the test | ||
const version = await krunkitHelper.getKrunkitVersion(); | ||
|
||
expect(version).toBe('0.1.2'); | ||
|
||
// expect called with qemu-system-aarch64 (as it's arm64) | ||
expect(extensionApi.process.exec).toHaveBeenCalledWith('krunkit', ['--version'], undefined); | ||
}); | ||
|
||
test('should grab correct version using a given path', async () => { | ||
const output = `krunkit 0.1.2 | ||
`; | ||
|
||
(extensionApi.process.exec as Mock).mockReturnValue({ | ||
stdout: output, | ||
} as extensionApi.RunResult); | ||
|
||
const fakePath = '/my-dummy-path'; | ||
|
||
const version = await krunkitHelper.getKrunkitVersion(fakePath); | ||
|
||
expect(version).toBe('0.1.2'); | ||
|
||
expect(extensionApi.process.exec).toHaveBeenCalledWith('krunkit', ['--version'], { | ||
env: { | ||
PATH: fakePath, | ||
}, | ||
}); | ||
}); |
Oops, something went wrong.