Skip to content

Commit 4b67a37

Browse files
committed
use same user again for doing the tests
1 parent dea3465 commit 4b67a37

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

tests/rspec/test.rb

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -59,21 +59,25 @@
5959
# Parse wp-cli siteurl into smaller parts
6060
uri = URI(target_url)
6161

62-
# Create random test user, try to login with it and delete it after tests
63-
username = "wp-palvelu-tester-#{Time.now.to_i}"
62+
# Use this specific user for tests
63+
username = "wp-rspec-test-user"
6464
password = rand(36**32).to_s(36)
65-
system "wp user create #{username} #{username}@#{uri.host} --user_pass=#{password} --role=administrator"
65+
system "wp user create #{username} #{username}@#{uri.host} --user_pass=#{password} --role=administrator --first_name=WP --last_name=Rspec-Test-Bot > /dev/null 2>&1"
66+
unless $?.success?
67+
system "wp user update #{username} --user_pass=#{password} --role=administrator > /dev/null 2>&1"
68+
end
6669

6770
# If we couldn't create user just skip the last test
6871
unless $?.success?
6972
username = nil
7073
end
7174

72-
# Cleanup afterwise
75+
# After the tests put user into lesser mode so that it's harmless
76+
# This way tests won't increase the index of user IDs everytime
7377
RSpec.configure do |config|
7478
config.after(:suite) {
7579
puts "\ndoing the cleanup..."
76-
system "wp user delete #{username} --yes"
80+
system "wp user update #{username} --role=subscriber > /dev/null 2>&1"
7781
}
7882
end
7983

0 commit comments

Comments
 (0)