Skip to content

Commit

Permalink
add tests for previous & timestamps flags on log requests
Browse files Browse the repository at this point in the history
  • Loading branch information
ewilken committed Sep 6, 2023
1 parent 93c49f0 commit c5fccd9
Showing 1 changed file with 27 additions and 3 deletions.
30 changes: 27 additions & 3 deletions Tests/SwiftkubeClientTests/RequestBuilderTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -76,28 +76,52 @@ final class RequestBuilderTests: XCTestCase {

func testFollowInNamespace() {
let builder = RequestBuilder(config: config, gvr: gvr)
let request = try? builder.in(.system).toFollow(pod: "pod", container: "container").build()
let request = try? builder.in(.system).toFollow(pod: "pod", container: "container", timestamps: false).build()

XCTAssertEqual(request?.url, URL(string: "https://kubernetesmaster/api/v1/namespaces/kube-system/pods/pod/log?follow=true&container=container")!)
XCTAssertEqual(request?.method, HTTPMethod.GET)
}

func testFollowWithTimestampsInNamespace() {
let builder = RequestBuilder(config: config, gvr: gvr)
let request = try? builder.in(.system).toFollow(pod: "pod", container: "container", timestamps: true).build()

XCTAssertEqual(request?.url, URL(string: "https://kubernetesmaster/api/v1/namespaces/kube-system/pods/pod/log?follow=true&timestamps=true&container=container")!)
XCTAssertEqual(request?.method, HTTPMethod.GET)
}

func testLogsInNamespace() {
let builder = RequestBuilder(config: config, gvr: gvr)
let request = try? builder.in(.system).toLogs(pod: "pod", container: nil).build()
let request = try? builder.in(.system).toLogs(pod: "pod", container: nil, previous: false, timestamps: false).build()

XCTAssertEqual(request?.url, URL(string: "https://kubernetesmaster/api/v1/namespaces/kube-system/pods/pod/log")!)
XCTAssertEqual(request?.method, HTTPMethod.GET)
}

func testLogsWithContainerInNamespace() {
let builder = RequestBuilder(config: config, gvr: gvr)
let request = try? builder.in(.system).toLogs(pod: "pod", container: "container").build()
let request = try? builder.in(.system).toLogs(pod: "pod", container: "container", previous: false, timestamps: false).build()

XCTAssertEqual(request?.url, URL(string: "https://kubernetesmaster/api/v1/namespaces/kube-system/pods/pod/log?container=container")!)
XCTAssertEqual(request?.method, HTTPMethod.GET)
}

func testLogsWithPreviousInNamespace() {
let builder = RequestBuilder(config: config, gvr: gvr)
let request = try? builder.in(.system).toLogs(pod: "pod", container: nil, previous: true, timestamps: false).build()

XCTAssertEqual(request?.url, URL(string: "https://kubernetesmaster/api/v1/namespaces/kube-system/pods/pod/log?previous=true")!)
XCTAssertEqual(request?.method, HTTPMethod.GET)
}

func testLogsWithTimestampsInNamespace() {
let builder = RequestBuilder(config: config, gvr: gvr)
let request = try? builder.in(.system).toLogs(pod: "pod", container: nil, previous: false, timestamps: true).build()

XCTAssertEqual(request?.url, URL(string: "https://kubernetesmaster/api/v1/namespaces/kube-system/pods/pod/log?timestamps=true")!)
XCTAssertEqual(request?.method, HTTPMethod.GET)
}

func testGetWithListOptions_Eq() {
let builder = RequestBuilder(config: config, gvr: gvr)
let request = try? builder.in(.default).toGet().with(options: [
Expand Down

0 comments on commit c5fccd9

Please sign in to comment.