spec/tracker_spec.rb in fastdfs-client-1.0.2 vs spec/tracker_spec.rb in fastdfs-client-1.2.0
- old
+ new
@@ -11,23 +11,23 @@
expect(FC::Socket).to receive(:new).with(host, port, nil)
FC::Tracker.new(host, port)
end
it "should have access to the storage connection" do
- expect(tracker.socket).to receive(:connection)
+ expect(tracker.socket).to receive(:connection).and_return({})
expect(tracker.socket).to receive(:close)
tracker.get_storage
end
it "should have access to the storage class" do
expect(tracker.get_storage.class).to eq(FC::Storage)
end
it "verify the server address and port" do
- expect(tracker.get_storage.host).to eq(TestConfig::STORAGE_IP)
+ expect(tracker.get_storage.socket.host).to eq(TestConfig::STORAGE_IP)
#[0, 0, 0, 0, 0, 89, 216, 0]
- expect(tracker.get_storage.port.to_s).to eq(TestConfig::STORAGE_PORT)
+ expect(tracker.get_storage.socket.port.to_s).to eq(TestConfig::STORAGE_PORT)
expect(tracker.get_storage.store_path).to eq(TestConfig::STORE_PATH)
end
it "get to the server failed" do
result = FC::ProtoCommon.header_bytes(FC::CMD::RESP_CODE, 0, 22)
@@ -35,16 +35,23 @@
expect(tracker.get_storage).to be_a_kind_of(Hash)
expect(tracker.get_storage[:status]).to be_falsey
end
it "run server flow" do
- 1.times.map do
- tracker.get_storage
+ items = 5.times.map do
+ Thread.new do
+ storage = tracker.get_storage
+ results = storage.upload(File.open(File.expand_path("../page.png", __FILE__)))[:result]
+ puts results
+ puts storage.delete(results[:path], results[:group_name])
+ end
end
+ items.each{|item| item.join }
+
# storage = tracker.get_storage
# puts "#{storage.host}, #{storage.port}"
- # results = storage.upload(File.open("/Users/huxinghai/Documents/shark/app/assets/images/page.png"))
+ # results = storage.upload(File.open("page.png"))
# puts results
# puts storage.delete(results[:path], results[:group_name])
end
end
\ No newline at end of file