#
# Commands covered: tserialport::manifest tserialport::build-info
#

#
# (c) 2025 Alexander Schoepe
#
# See the file "license.terms" for information on usage and redistribution
# of this file, and for a DISCLAIMER OF ALL WARRANTIES.
#

if {[lsearch [namespace children] ::tcltest] == -1} {
  package require tcltest 2
  namespace import -force ::tcltest::*
  loadTestedCommands
}

package require tserialport

test manifest-1.1 {manifest takes no args} -body {
  tserialport::manifest extra
} -returnCodes error -match glob -result "wrong # args: should be \"tserialport::manifest*\""

test manifest-1.2 {manifest returns dict} {
  dict size [tserialport::manifest]
} 5

test manifest-1.3 {manifest contains version key} {
  dict exists [tserialport::manifest] version
} 1

test manifest-1.4 {manifest contains date key} {
  dict exists [tserialport::manifest] date
} 1

test manifest-1.5 {manifest contains uuid key} {
  dict exists [tserialport::manifest] uuid
} 1

test manifest-1.6 {manifest contains build-hash key} {
  dict exists [tserialport::manifest] build-hash
} 1

test manifest-1.7 {manifest contains check-in key} {
  dict exists [tserialport::manifest] check-in
} 1

test manifest-1.8 {manifest uuid length} {
  string length [dict get [tserialport::manifest] uuid]
} 64

test manifest-1.9 {manifest check-in is prefix of uuid} {
  set manifest [tserialport::manifest]
  set uuid [dict get $manifest uuid]
  set checkin [dict get $manifest check-in]
  string match "${checkin}*" $uuid
} 1

test build-info-1.1 {build-info command exists in Tcl 9.0+} -body {
  if {[package vsatisfies [package provide Tcl] 9.0-]} {
    info commands ::tserialport::build-info
  } else {
    # Tcl < 9.0, skip test
    list ::tserialport::build-info
  }
} -result {::tserialport::build-info}

# cleanup
::tcltest::cleanupTests
return
