#------------------------------------------------------------------------------- # Copyright (c) 2010, Perforce Software, Inc. All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are met: # # 1. Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # # 2. Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. # # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS # FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL PERFORCE # SOFTWARE, INC. BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON # ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR # TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF # THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH # DAMAGE. #------------------------------------------------------------------------------- class TC_Streams < Test::Unit::TestCase include P4RubyTest def name "Test streams" end def test_streams_depot # Create a streams depot p4.connect depot = p4.fetch_depot( "Stream" ) depot[ 'type' ] = "stream" p4.save_depot( depot ) # Check the number of depots returned with default options len = p4.run_depots.length assert_equal( 2, len, "default: Wrong number of depots:" ) # Fetch a stream from the server, check that # an 'extraTag' field (such as 'firmerThanParent' exists, and save # the spec s = p4.fetch_stream( "//Stream/MAIN" ) assert(s.has_key?("firmerThanParent"), "'extraTag' field missing from spec." ) s[ 'Type' ] = "mainline" o = p4.save_stream( s ) p4.disconnect # MUST disconnect and reconnect because there is a problem with streams # caching in the server. If we don't disconnect/reconnect 'p4 streams' # returns with the warning 'No such streams', as if the stream hasn't # been saved. p4.connect len = p4.run_streams.length assert_equal( 1, len, "Failed to save stream spec" ) # Disable streams assert( p4.api_level >= 70, "API level (#{p4.api_level}) too low" ) p4.streams=false assert( !p4.streams?, "Failed to disable streams" ) len = p4.run_depots.length assert_equal( 1, len, "streams=false: Wrong number of depots:" ) # Enable streams and set the api_level < 70 p4.streams=true assert( p4.streams?, "Failed to enable streams" ) p4.api_level = 69 assert( p4.api_level < 70, "API level (#{p4.api_level}) too high" ) len = p4.run_depots.length assert_equal( 1, len, "api_level=69: Wrong number of depots:" ) p4.run_streams p4.disconnect end end