Skip to content

Commit

Permalink
fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
ccheetham committed Jul 19, 2018
1 parent 8bb07ab commit 8454070
Show file tree
Hide file tree
Showing 11 changed files with 178 additions and 22 deletions.
4 changes: 2 additions & 2 deletions Configuration/src/AspDotNetCore/Simple/Simple.feature
Expand Up @@ -6,7 +6,7 @@ Feature: Simple Configuration

@netcoreapp2.1
Scenario Outline: Simple Configuration for .Net Core 2.1
Given you have .NET Core SDK 2.1.300 installed
Given you have at least .NET Core SDK 2.1.300 installed
And you have Java 8 installed
And you have Apache Maven 3 installed
When you run: git clone https://github.com/spring-cloud/spring-cloud-config
Expand All @@ -28,7 +28,7 @@ Feature: Simple Configuration

@net461
Scenario Outline: Simple Configuration for .Net Framework 4.6.1
Given you have .NET Core SDK 2.1.300 installed
Given you have at least .NET Core SDK 2.1.300 installed
And you have Java 8 installed
And you have Apache Maven 3 installed
When you run: git clone https://github.com/spring-cloud/spring-cloud-config
Expand Down
Expand Up @@ -6,7 +6,7 @@ Feature: Simple CloudFoundry Configuration
@netcoreapp2.1
@win10-x64
Scenario: Simple CloudFoundry Configuration for .Net Core 2.1 (win10-x64)
Given you have .NET Core SDK 2.1.300 installed
Given you have at least .NET Core SDK 2.1.300 installed
And you have CloudFoundry service p-config-server installed
When you run: cf create-service p-config-server standard myConfigServer -c ./config-server.json
And you wait until CloudFoundry service myConfigServer is created
Expand All @@ -20,7 +20,7 @@ Feature: Simple CloudFoundry Configuration
@netcoreapp2.1
@ubuntu.14.04-x64
Scenario: Simple CloudFoundry Configuration for .Net Core 2.1 (ubuntu.14.04-x64)
Given you have .NET Core SDK 2.1.300 installed
Given you have at least .NET Core SDK 2.1.300 installed
And you have CloudFoundry service p-config-server installed
When you run: cf create-service p-config-server standard myConfigServer -c ./config-server.json
And you wait until CloudFoundry service myConfigServer is created
Expand All @@ -34,7 +34,7 @@ Feature: Simple CloudFoundry Configuration
@net461
@win10-x64
Scenario: Simple CloudFoundry Configuration for .Net Framework 4.6.1 (win10-x64)
Given you have .NET Core SDK 2.1.300 installed
Given you have at least .NET Core SDK 2.1.300 installed
And you have CloudFoundry service p-config-server installed
When you run: cf create-service p-config-server standard myConfigServer -c ./config-server.json
And you wait until CloudFoundry service myConfigServer is created
Expand Down
6 changes: 3 additions & 3 deletions Connectors/src/AspDotNetCore/MySql/MySql.feature
Expand Up @@ -6,7 +6,7 @@ Feature: MySql Connector
@netcoreapp2.1
@win10-x64
Scenario: MySql Connector for .Net Core 2.1 (win10-x64)
Given you have .NET Core SDK 2.1.300 installed
Given you have at least .NET Core SDK 2.1.300 installed
And you have CloudFoundry service p-mysql installed
When you run: cf create-service p-mysql 100mb myMySqlService
And you wait until CloudFoundry service myMySqlService is created
Expand All @@ -21,7 +21,7 @@ Feature: MySql Connector
@netcoreapp2.1
@ubuntu.14.04-x64
Scenario: MySql Connector for .Net Core 2.1 (ubuntu.14.04-x64)
Given you have .NET Core SDK 2.1.300 installed
Given you have at least .NET Core SDK 2.1.300 installed
And you have CloudFoundry service p-mysql installed
When you run: cf create-service p-mysql 100mb myMySqlService
And you wait until CloudFoundry service myMySqlService is created
Expand All @@ -36,7 +36,7 @@ Feature: MySql Connector
@net461
@win10-x64
Scenario: MySql Connector for .Net Framework 4.6.1 (win10-x64)
Given you have .NET Core SDK 2.1 installed
Given you have at least .NET Core SDK 2.1.300 installed
And you have CloudFoundry service p-mysql installed
When you run: cf create-service p-mysql 100mb myMySqlService
And you wait until CloudFoundry service myMySqlService is created
Expand Down
4 changes: 2 additions & 2 deletions Connectors/src/AspDotNetCore/MySqlEFCore/MySqlEFCore.feature
Expand Up @@ -6,7 +6,7 @@ Feature: MySqlEFCore Connector
@netcoreapp2.1
@win10-x64
Scenario: MySqlEFCore Connector for .Net Core 2.1 (win10-x64)
Given you have .NET Core SDK 2.1.300 installed
Given you have at least .NET Core SDK 2.1.300 installed
And you have CloudFoundry service p-mysql installed
When you run: cf create-service p-mysql 100mb myMySqlService
And you wait until CloudFoundry service myMySqlService is created
Expand All @@ -21,7 +21,7 @@ Feature: MySqlEFCore Connector
@netcoreapp2.1
@ubuntu.14.04-x64
Scenario: MySqlEFCore Connector for .Net Core 2.1 (ubuntu.14.04-x64)
Given you have .NET Core SDK 2.1.300 installed
Given you have at least .NET Core SDK 2.1.300 installed
And you have CloudFoundry service p-mysql installed
When you run: cf create-service p-mysql 100mb myMySqlService
And you wait until CloudFoundry service myMySqlService is created
Expand Down
Expand Up @@ -6,7 +6,7 @@ Feature: PostgreEFCore Connector
@netcoreapp2.1
@win10-x64
Scenario: PostgreEFCore Connector for .Net Core 2.1 (win10-x64)
Given you have .NET Core SDK 2.1.300 installed
Given you have at least .NET Core SDK 2.1.300 installed
And you have CloudFoundry service EDB-Shared-PostgreSQL installed
When you run: cf create-service EDB-Shared-PostgreSQL "Basic PostgreSQL Plan" myPostgres
And you wait until CloudFoundry service myPostgres is created
Expand All @@ -21,7 +21,7 @@ Feature: PostgreEFCore Connector
@netcoreapp2.1
@ubuntu.14.04-x64
Scenario: PostgreEFCore Connector for .Net Core 2.1 (ubuntu.14.04-x64)
Given you have .NET Core SDK 2.1.300 installed
Given you have at least .NET Core SDK 2.1.300 installed
And you have CloudFoundry service EDB-Shared-PostgreSQL installed
When you run: cf create-service EDB-Shared-PostgreSQL "Basic PostgreSQL Plan" myPostgres
And you wait until CloudFoundry service myPostgres is created
Expand Down
4 changes: 2 additions & 2 deletions Connectors/src/AspDotNetCore/PostgreSql/PostgreSql.feature
Expand Up @@ -6,7 +6,7 @@ Feature: PostgreSql Connector
@netcoreapp2.1
@win10-x64
Scenario: PostgreSql Connector for .Net Core 2.1 (win10-x64)
Given you have .NET Core SDK 2.1.300 installed
Given you have at least .NET Core SDK 2.1.300 installed
And you have CloudFoundry service EDB-Shared-PostgreSQL installed
When you run: cf create-service EDB-Shared-PostgreSQL "Basic PostgreSQL Plan" myPostgres
And you wait until CloudFoundry service myPostgres is created
Expand All @@ -21,7 +21,7 @@ Feature: PostgreSql Connector
@netcoreapp2.1
@ubuntu.14.04-x64
Scenario: PostgreSql Connector for .Net Core 2.1 (ubuntu.14.04-x64)
Given you have .NET Core SDK 2.1.300 installed
Given you have at least .NET Core SDK 2.1.300 installed
And you have CloudFoundry service EDB-Shared-PostgreSQL installed
When you run: cf create-service EDB-Shared-PostgreSQL "Basic PostgreSQL Plan" myPostgres
And you wait until CloudFoundry service myPostgres is created
Expand Down
6 changes: 3 additions & 3 deletions Connectors/src/AspDotNetCore/RabbitMQ/RabbitMQ.feature
Expand Up @@ -6,7 +6,7 @@ Feature: RabbitMQ Connector
@netcoreapp2.1
@win10-x64
Scenario: Rabbit Connector for .Net Core 2.1 (win10-x64)
Given you have .NET Core SDK 2.1.300 installed
Given you have at least .NET Core SDK 2.1.300 installed
And you have CloudFoundry service p-rabbitmq installed
When you run: cf create-service p-rabbitmq standard myRabbitMQService
And you wait until CloudFoundry service myRabbitMQService is created
Expand All @@ -21,7 +21,7 @@ Feature: RabbitMQ Connector
@netcoreapp2.1
@ubuntu.14.04-x64
Scenario: Rabbit Connector for .Net Core 2.1 (ubuntu.14.04-x64)
Given you have .NET Core SDK 2.1.300 installed
Given you have at least .NET Core SDK 2.1.300 installed
And you have CloudFoundry service p-rabbitmq installed
When you run: cf create-service p-rabbitmq standard myRabbitMQService
And you wait until CloudFoundry service myRabbitMQService is created
Expand All @@ -36,7 +36,7 @@ Feature: RabbitMQ Connector
@net461
@win10-x64
Scenario: Rabbit Connector for .Net Framework 4.6.1 (win10-x64)
Given you have .Net Core SDK 2.1.300 installed
Given you have at least .NET Core SDK 2.1.300 installed
And you have CloudFoundry service p-rabbitmq installed
When you run: cf create-service p-rabbitmq standard myRabbitMQService
And you wait until CloudFoundry service myRabbitMQService is created
Expand Down
3 changes: 1 addition & 2 deletions pyenv.pkgs
Expand Up @@ -13,6 +13,7 @@ jedi==0.12.0
lxml==4.2.1
MechanicalSoup==0.10.0
mock==2.0.0
nose==1.3.7
parse==1.8.2
parse-type==0.4.2
parso==0.2.0
Expand All @@ -24,11 +25,9 @@ psutil==5.4.5
ptyprocess==0.5.2
Pygments==2.2.0
requests==2.18.4
setuptools==39.1.0
simplegeneric==0.8.1
six==1.11.0
sure==1.4.9
traitlets==4.3.2
urllib3==1.22
wcwidth==0.1.7
wheel==0.31.0
75 changes: 75 additions & 0 deletions pylib/version.py
@@ -0,0 +1,75 @@
class Version:

def __init__(self, version):
self.version = version

def __repr__(self):
return self.version

def __eq__(self, other):
return Comparator().compare(self.version, other.version) == 0

def __ne__(self, other):
return not self == other

def __lt__(self, other):
return Comparator().compare(self.version, other.version) < 0

def __le__(self, other):
return Comparator().compare(self.version, other.version) <= 0

def __gt__(self, other):
return Comparator().compare(self.version, other.version) > 0

def __ge__(self, other):
return Comparator().compare(self.version, other.version) >= 0


class Comparator:

'''
A comparator that semantically sorts versions. This comparator considers,
e.g., "10" to be greater than "9", in contrast to a lexical comparison.
Return:
0 if version a == version b
<0 if version a < version b
>0 if version a > version b
Rules:
* version strings are broken into nodes delimited by '.'
* comparison is initially on the first node of each version
* if each node can both be converted to an integer, they are compared as such
* otherwise, the nodes are compared as strings
* if the comparison result of the first nodes is not 0, that result is returned
* else, the first nodes are equal
* if neither version has addition nodes, 0 is returned
* if each version has additional nodes, those nodes are compared as above
* else the version with the no more nodes remaining is considered the lesser version
'''
def compare(self, a, b):
if a is None or b is None:
raise ValueError('version string cannot be None')
if not(isinstance(a, Version) or isinstance(a, str)) or not(isinstance(b, Version) or isinstance(b, str)):
raise TypeError('version must be an instance of a Version or str')
if not a or not b:
raise ValueError('version string cannot be empty')
def compareNodes(anodes, bnodes):
if len(anodes) == 0 and len(bnodes) == 0:
return 0
if len(anodes) == 0:
return -1
if len(bnodes) == 0:
return 1
anode, bnode = anodes[0], bnodes[0]
try:
anode, bnode = int(anode), int(bnode)
except ValueError:
pass
if anode > bnode:
return 1
elif anode < bnode:
return -1
else:
return compareNodes(anodes[1:], bnodes[1:])
return compareNodes(a.split('.'), b.split('.'))
80 changes: 80 additions & 0 deletions pylib/version_test.py
@@ -0,0 +1,80 @@
import sure
import unittest
import version

class VersionTest(unittest.TestCase):

def testStringRepresentation(self):
myversion = version.Version('1.2.3')
repr(myversion).should.equal('1.2.3')

def testEqual(self):
a = version.Version('1.2.3')
b = version.Version('1.2.3')
a.should.equal(b)

def testNotEqual(self):
a = version.Version('1.2.3')
b = version.Version('1.2.4')
a.should_not.equal(b)

def testGreaterThan(self):
a = version.Version('10')
b = version.Version('9')
(a > b).should.be.true

def testGreaterThanOrEquals(self):
a = version.Version('10')
b = version.Version('9')
c = version.Version('10')
(a >= b).should.be.true
(a >= c).should.be.true

def testLessThan(self):
a = version.Version('9')
b = version.Version('10')
(a < b).should.be.true

def testLessThanOrEqual(self):
a = version.Version('9')
b = version.Version('10')
c = version.Version('9')
(a <= b).should.be.true
(a <= c).should.be.true

class ComparatorTest(unittest.TestCase):

def setUp(self):
self.comparator = version.Comparator()

def testEqual(self):
(self.comparator.compare('1.2.3', '1.2.3') == 0).should.be.true

def testNumericComparison(self):
(self.comparator.compare('10', '9') > 0).should.be.true
(self.comparator.compare('9', '10') < 0).should.be.true

def testAlphaComparsion(self):
(self.comparator.compare('z', 'a') > 0).should.be.true
(self.comparator.compare('a', 'z') < 0).should.be.true

def testAlphaNumberComparison(self):
(self.comparator.compare('a', '1') > 0).should.be.true
(self.comparator.compare('1', 'a') < 0).should.be.true

def testDifferentNodeLengths(self):
(self.comparator.compare('1.2.3', '1.2') > 0).should.be.true
(self.comparator.compare('1.2', '1.2.3') < 0).should.be.true

def testValueError(self):
self.assertRaises(ValueError, self.comparator.compare, '1.2.3', '')
self.assertRaises(ValueError, self.comparator.compare, '', '1.2.3')
self.assertRaises(ValueError, self.comparator.compare, '1.2.3', None)
self.assertRaises(ValueError, self.comparator.compare, None, '1.2.3')

def testTypeError(self):
self.assertRaises(TypeError, self.comparator.compare, '1.2.3', 0)
self.assertRaises(TypeError, self.comparator.compare, 0, '1.2.3')

if __name__ == '__main__':
unittest.main()
8 changes: 5 additions & 3 deletions steps/tool_steps.py
@@ -1,12 +1,14 @@
import command
import re
from version import Version

@given(u'you have .NET Core SDK {version} installed')
@given(u'you have at least .NET Core SDK {version} installed')
def step_impl(context, version):
expected = Version(version)
cmd = command.Command(context, "dotnet --version")
cmd.run()
actual = cmd.stdout
actual.should.match(r'{}.*'.format(version))
actual = Version(cmd.stdout)
(actual >= expected).should.be.true

@given(u'you have Java {version} installed')
def step_impl(context, version):
Expand Down

0 comments on commit 8454070

Please sign in to comment.