Files
swift-nio-imap/Tests/NIOIMAPTests/CommandEncoder+Tests.swift
T
David Evans 701d2d54d7 Refactor and fix Append (#228)
* Support encoding append commands

* Yay it works

* Cleanup 1

* Cleanup 2

* Fix sanity

* Fix command decoder test

* Fix parsing partial commands sync literals

* Fix parser stress tests

* Fix tests

* Remove unused code

* Code refactor and cleanup

* Fix sanity

* Tests

* Tests and sanity

* Encode AppendCommand tests

* Fix sanity
2020-06-30 12:56:56 +01:00

41 lines
1.3 KiB
Swift

//===----------------------------------------------------------------------===//
//
// This source file is part of the SwiftNIO open source project
//
// Copyright (c) 2020 Apple Inc. and the SwiftNIO project authors
// Licensed under Apache License v2.0
//
// See LICENSE.txt for license information
// See CONTRIBUTORS.txt for the list of SwiftNIO project authors
//
// SPDX-License-Identifier: Apache-2.0
//
//===----------------------------------------------------------------------===//
import NIO
@testable import NIOIMAP
@testable import NIOIMAPCore
import NIOTestUtils
import XCTest
final class CommandEncoder_Tests: XCTestCase {}
extension CommandEncoder_Tests {
func testThrowsIfMissingBytes() {
let encoder = CommandEncoder()
var out = ByteBuffer()
XCTAssertNoThrow(try encoder.encode(data: .append(.start(tag: "1", appendingTo: .inbox)), out: &out))
out.clear()
XCTAssertNoThrow(try encoder.encode(data: .append(.beginMessage(messsage: .init(options: .init(flagList: [], extensions: []), data: .init(byteCount: 10)))), out: &out))
out.clear()
XCTAssertNoThrow(try encoder.encode(data: .append(.messageBytes("12345")), out: &out))
out.clear()
XCTAssertThrowsError(try encoder.encode(data: .append(.endMessage), out: &out))
}
}